Copy link to clipboard
Copied
Hi.
I've created a simple class in Scala and packed it into a .jar file. I have no problems loading it into ColdFusion and running its methods.
Here is a copy of cfdump of the created object:
| object of example.HelloWorld | ||
| Class Name | example.HelloWorld | |
| Methods | Method | Return Type |
| Country() | example.HelloWorld$Country$ | |
| cn() | example.HelloWorld$Country | |
| countriesList() | scala.collection.immutable.List | |
| countriesMap() | scala.collection.immutable.Map | |
| getCountryByCode(java.lang.String) | scala.Option | |
| ja() | example.HelloWorld$Country | |
| ru() | example.HelloWorld$Country | |
| us() | example.HelloWorld$Country | |
But I have problems with isInstanceOf function with this object. If I run:
HelloWorldApp = CreateObject("java","example.HelloWorld");
writeOutput(isInstanceOf(HelloWorldApp,"example.HelloWorld"));
I get false as a result, but it should be true, right? The class does get loaded properly by CreateObject function.
Is there a workaround? The cfdump tag somehow manages to get the proper type of the object which it displays in the Class Name field of the dump table.
Thank you.
Copy link to clipboard
Copied
If you're up for it, I just thought of another test. At least for the time being. I am assuming the JAR file is at the original location,
C:\ColdFusion10\cfusion\wwwroot\org\cfjava\jars\cfjavatest.jar
In Application.cfc, comment out all the lines involving this.javaSettings. Go to the Java and JVM page in the Administrator. Add the following to the classpath:
C:/ColdFusion10/cfusion/wwwroot/org/cfjava/jars/;C:/ColdFusion10/cfusion/wwwroot/org/cfjava/jars/cfjavatest.jar
Press the button to submit the changes. To be sure, restart ColdFusion.
Any joy?
Copy link to clipboard
Copied
Thanks for the JAR file. Here follows my progress report.
As a first test, I commented out the code this.javasettings=.... I unpacked the JAR file and copied its contents (example and scala directories) to C:\ColdFusion10\cfusion\wwwroot\WEB-INF\classes\. I restarted ColdFusion. When I run your original isInstanceOf code, I get a Yes.
Copy link to clipboard
Copied
I have been able to reproduce the issue (failure of isInstanceOf with dynamic Java settings) time after time. I am beginning to wonder whether you have uncovered a bug. However, I did find another positive result.
Comment out the code this.javasettings=.... Move the file cfjavatest.jar to the directory,
C:\ColdFusion10\cfusion\wwwroot\WEB-INF\lib\
Restart ColdFusion. When you run the original isInstanceOf code, you get a Yes.
Copy link to clipboard
Copied
@Kirill_Grishin
I decided to round this up before the end of the year. I am sorry I haven't been able to do better than find the above workarounds.
IsInstanceOf(helloworldapp,"example.HelloWorld")) continues to return No for dynamic Java settings. I have reproduced the behaviour using every conceivable directory structure in the loadPaths attribute in this.javaSettings. As far as I can see, what you have discovered is a bug.
Please consider filing a bug report. In fact, someone reported a similar bug (3121307) as far back as February 2012, when ColdFusion 10 was still in pre-release beta. Apparently that problem remains unsolved!
Copy link to clipboard
Copied
Hang on a minute! I have this niggling feeling ColdFusion's isInstanceOf might be expecting the qualified name jars.example.HelloWorld.
Just for giggles, run the original index.cfm page one directory up, in the jars directory. That is, make a copy to
C:\ColdFusion10\cfusion\wwwroot\org\cfjava\jars\index.cfm
and run it.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more