6

I have some code which works under Railo, but am trying to get this particular app working on CF10 and CF11

It's a cfWheels app, and I've got a BCrypt.class file in the /miscellaneous/ directory.

In my /events/onapplicationstart.cfm file, I've got:

application.bCrypt = CreateObject( "java", "BCrypt", "/miscellaneous/" );

This works in Railo; but in CF11 I get

The java object type is unknown for the CreateObject function.

Verify the type of your object when creating it and try again. 
Valid Types are : component | java | webservice | dotnet | com | corba | .NET


The error occurred in /Volumes/Documents/blah/public/events/onapplicationstart.cfm: line 8
Called from /Volumes/Documents/blah/public/wheels/global/cfml.cfm: line 111
Called from /Volumes/Documents/blah/public/wheels/events/onapplicationstart.cfm: line 388
6 : 
7 :     // BCrypt library
8 :     application.bCrypt = CreateObject( "java", "BCrypt", "/miscellaneous/" );
9 : 
10 :    // Application Specific settings

I assume it's just a syntax thing? Can I call a .class file in this manner on CF10/11 ?

5
  • 2
    Adobe CF's createObject only has two arguments. The type and the class. The class file itself has to be put in the cfusion\wwwroot\WEB-INF\classes folder Commented May 26, 2015 at 9:24
  • Ah thanks, needed: this.javaSettings = { LoadPaths = ["/miscellaneous"] }; and then only use CreateObject( "java", "BCrypt" ); Commented May 26, 2015 at 9:29
  • Reopening because the claim that this question was a duplicate of another wasn't accurate. It was a similar situation, but not the same. Commented May 26, 2015 at 9:33
  • @Neokoenig: you might wanna make your comment into an answer. Commented May 26, 2015 at 9:33
  • @haxtbh - That was a reasonable explanation (and turned out to be the problem). Next time, post it as an answer so folks can vote on it :) Commented Jun 3, 2015 at 1:47

1 Answer 1

5

Ah thanks all. As haxtbh said in the comments, the problem was

Adobe CF's createObject only has two arguments. The type and the class.

So I needed to put:

this.javaSettings = { LoadPaths = ["/miscellaneous"] };

in /config/app.cfm

and then use

CreateObject( "java", "BCrypt" );

in /events/onapplicationstart.cfm

Sign up to request clarification or add additional context in comments.

1 Comment

By default the ColdFusion server caches class file on first load, you can choose to reload fresh copy every time using reloadOnChange="true" as one of the parameters. During development it is really helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.