Use java class in ColdFusion11. Java object type unknown for CreateObject function

I have code that works under Railo, but I'm trying to get this particular application to work with CF10 and CF11

This is a cfWheels application, and I have a BCrypt.class file in the /miscellaneous/ directory.

In my /events/onapplicationstart.cfm file, I have:

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

It 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 this is just the syntax? Can I call a .class file this way on CF10 / 11?

+5
source share
1 answer

Thanks to everyone. As haxtbh said in the comments , the problem was

Adobe CF createObject has only two arguments. Type and class.

Therefore, I had to put:

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

in / config / app.cfm

and then use

CreateObject( "java", "BCrypt" );

in / events / onapplicationstart.cfm

+5
source

All Articles