Reputation: 1779
I want to access a JAVA function from CFML script:
<cfscript>
authToken = createobject("java","coldfusion.security.SecurityManager").createAuthToken('admin', 'cfadmin', '12345', false);
</cfscript>
<cfoutput>authToken: #authToken#</cfoutput>
I got the following error:
Object instantiation exception.
An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. If the class has a constructor that accepts an argument, you must call the constructor explicitly using the init(args) method. Error : coldfusion.security.SecurityManager
I know is because the arguments passed directly to createAuthToken
that I can't do and I should init() it. How can I correctly pass the arguments in this scenario?
Upvotes: 0
Views: 829
Reputation: 29870
It pretty much tells you what you need to do in the error message. But for the sake of clarity:
<cfset authToken = createobject("java","coldfusion.security.SecurityManager")
.init() // you might need some init() args here?
.createAuthToken('admin', 'cfadmin', '12345', false)
>
I'm not really sure why you bother to put that sinple statement into a <cfscript>
block, btw. Would not a <cfset>
do?
Upvotes: 2