I am not sure I am understanding you with this
var temp = getPlugin(“JavaLoader”).create(“net.sourceforge.wurfl.core.CustomWURFLHolder”).init(wurflObj);
manager = temp.getWURFLManager();
If I replace the logic to be
var temp = createObject(java, “net.sourceforge.wurfl.core.CustomWURFLHolder”).init(wurflObj);
manager = temp.getWURFLManager();
It works fine.
If that first code sample above is the one returning the “The class must not be an interface or an abstract class” error, then I’m not sure what the problem might be. I was simply asking if you had really been inadvertanlty trying to create an instance of WURFLHolder instead of CustomWURFLHolder depsite what you pasted in.
I dont think you understand the last one, I said I am getting an instance of the class.
Not with the code you posted, you aren’t. This from the JavaLoader docs:
This works exactly the same as createObject(“java”, className), such that simply calling create(className)
gives you access to the static properties of the class, but to get an instance through calling the
Constructor you are required to call create(className).init();
And when you dump it out it is clear that method exists,
Yes, if you dump out the static class definition you would see the method name in there, but you aren’t dumping an actual instance of the class. Besides that, WURFLHolder is an interface so you aren’t going to be able to call the methods anyway.
and yet when you call it the messages says there are no methods that match, and that I should be using JavaCast. Now as the JavaDocs tell me that the method takes no arguments, I am not really sure what I can do there.
I think the javaCast() bit in the error message is just trying to be helpful. WURFLHolder is abstract, and most likley a red herring.
But the real problem is the first example, if I dump the jar file into a known class path and instantiate using createObject I have no problem. Yet if I remove that object from the class path an try to use the JavaLoader I get the problem.
Yeah, I don’t have a good answer for that. I downloaded the WURFL jar to play with it and I see the same “An exception occurred when instantiating a Java object.” error when trying to initialize an instance of CustomWURFLHolder with javaloader. I’m kind of curious if the fact that the CustomWURFLHolder class has a protected method called “init” has anything to do with it. If not, it probably has something to do with another class path that’s not being found when using javaloader. The site mentions that it is dependant on xercesImpl.jar and xmlParserAPIs.jar. There’s a chance they’re being found in the classpath when using createObject, but not by javaloader. Mark Mandel hangs out on this list so he will hopefully chime in. If not, you can post over on the javaloader list. http://groups.google.com/group/javaloader-dev
And the init() is only used if it has a constructor too Brad, which the second way I am trying doesnt have a constructor.
Actually all Java classes have a constructor. If you don’t type it in, the compiler creates one for you. Also, if you don’t explicitly call it with init(), ColdFusion will call the default constructor for you. So, you can get away with not calling init explicitly if the default constructor for a class accepts no arguments, but don’t be fooled-- it’s getting called behind the scenes. That doesn’t change the fact that WURFLHolder is an interface with abstract methods which cannot be called though.
If you find the answer off-list, please do post it. I’m really curious now what is causing your error initializing the CustomWURFLHolder class.
Thanks!
~Brad