coldfusioncoldfusion-10railocfwheels

Use java class in ColdFusion11 - The java object type is unknown for the CreateObject function


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 ?


Solution

  • 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