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 ?

Tushar Bhaware
  • 2,525
  • 1
  • 16
  • 29
Neokoenig
  • 1,102
  • 7
  • 16
  • 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 – haxtbh May 26 '15 at 09:24
  • Ah thanks, needed: this.javaSettings = { LoadPaths = ["/miscellaneous"] }; and then only use CreateObject( "java", "BCrypt" ); – Neokoenig May 26 '15 at 09: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. – Adam Cameron May 26 '15 at 09:33
  • @Neokoenig: you might wanna make your comment into an answer. – Adam Cameron May 26 '15 at 09: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 :) – Leigh Jun 03 '15 at 01:47

1 Answers1

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

Community
  • 1
  • 1
Neokoenig
  • 1,102
  • 7
  • 16
  • 4
    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. – Anurag May 26 '15 at 10:30