This content has been marked as final. Show 20 replies
(Note: I would recommend you package up your class file into a jar file with your own package name.)
Place your packaged jar file containing the class file in your cf_webapp_root\WEB-INF\lib folder.
Read this tech note for more information
Additional info: Even though the tech note is for cfmx 7, it should still give you some useful information.
I appreciate the reply and link. I will check the path you specified. I thought you put classes under cf_webapp_root\WEB-INF\classes and .jar files under cf_webapp_root\WEB-INF\lib. But anything is worth a try since it will not be easier to get a classpath changed.
>> I thought you put classes cf_webapp_root\WEB-INF\classes
>> and .jar files under cf_webapp_root\WEB-INF\lib
That's correct. Place jar files in ...\lib and class files in the \classes directory. CF should automatically detect them on restart.
Oh, so you still have to hit restart even if the <reload>TRUE</reload> is set in the cf_root\wwwroot\WEB-INF\jrun-web.xml file?
That clears some things up... I read that it had problems but I thought it was because the setting above wasn't normally set....
The setting in jrun-web.xml is suppposed to work ... yes. I've personally had problems with it, but I've also heard of it working successfully for others. My suggestion is to enable the setting, restart .. drop a test class file in the ...\classes folder and see if CF recognizes it. If it does, then the setting works for you ;-)
Well, since right now I have my class under the cf_webapp_root\WEB-INF\classes and the reload option was ALREADY set, I am hoping that it is not working... and that's why it can't find my class file. Otherwise... I guess I have to figure out where weblogic is looking.
You must restart the first time you change the jrun-web.xml setting. Afterwards, you should not have to restart CF whenever you add a new class or jar to the WEB-INF folders. Assuming the setting works correctly.
Wish I knew more about weblogic paths. Out of curiousity, did you try adding a jar file to the "lib" directory?
No, but then I don't know much about java. Trying to do the simplest test I could to check configuration of the java (and that is working so well...) Not knowing java I used the code for a class file called simple math that I found in a little article and then did a createObject to call it and pass two numbers to add and output the result.
All I get is :
Object Instantiation Exception.
Class not found: SimpleMath.
Now i have tried to change the classpath in the regedit under the weblogic properties (don't like playing there) and it didn't work. I checked the cf admin and found that the changes didn't propogate, so obviously I am changing them in the wrong place. If this were through just cf on jrun I might have a chance, but now I am tackling two monsters I am unfamiliar with. I do appreciate all the help though. I know its difficult to help without being there to click.
If you have any suggestions on where to look (I know RTFM, but it is mostly geared towards an install not how to trace through config issues.) please feel free to put in two cents, or more.
Thanks a bunch,
When you checked the cfadmin what was the class path? I'm also wondering, do you have any other custom or special jars installed on the server. For example, some people install POI to create excel files. That jar has to be in the CF class path. So perhaps you could do a search to find out where the custom jars reside.
Stupid question, but you placed the compiled java .class files into the WEB-INF\classes directory, and not the .java source files right?
I f you want to try the jar method, here's a quicky on how to jar up your file as a package.
in a work folder, create a folder structure for your package, convention uses reverse internet domain (i.e. com.adobe.packagename)
for this one, we'll use a simple one level package called ironyx. So create a folder called ironyx.
copy the java file you want to package up into the ironyx folder
at the top of the java file place the following;
Compile the java file.
Using a command prompt in the parent folder of the ironyx folder, type the following;
jar -cf ironyx.jar ironyx
This will jar up the ironyx folder contents, including both the java and class files into an ironyx.jar file. You can delete the source java files prior to creation of the jar file if you wish.
Copy the jar file to ColdFusion WEB-INF\lib directory, bounce the cf instance
A typical cf execution might look like
<cfset mySimpleMath= CreateObject("java","ironyx.SimpleMath")>
<!--- Usually you Initialize the object, but that depends on the constructors of the class--->
<!--- Execute the method --->
<cfset result = mySimpleMath.addNumbers(num1, num2)>
Note: If you're using the SimpleMath class file from http://builder.com.com/5100-6370-5177283.html, they have a text formatting error for the method. There should be spaces in publicintaddNumbers and it should look like
public int addNumbers
Alright, works. It had to be changed through a weblogic classpath setting which when finding the right one propogated through coldfusion and worked.
And a very nice discovery is weblogic detects any class added without a restart.
I do have a problem with my calls now which c_wigginton might have the answer for in his last post for me. I will try it out.
New to java and weblogic... wow, fun in a nails down the chalkboard sort of way, but it should get better right? There always seems to be some fairly large knowledge leaps we have to make... thanks for helping!!!!
>>And a very nice discovery is weblogic detects any class
>>added without a restart.
That is nice!
>>wow, fun in a nails down the chalkboard sort of way,
>>but it should get better right?
Yes... after a little torture as you've discovered ;-)
>>It had to be changed through a weblogic classpath setting which when finding
>>the right one propogated through coldfusion and worked.
Just for future knowledge, what is the classpath setting /variable name? Never know when I might have to endure similar torture myself!
You can either do it in a startup script, which we did because there were some issues with our syntax so it is our "interim fix" with just set classpath = <-- which didn't work with just the append syntax, the whole thing had to be typed out, still not sure why...
But you should be able to fix the config.xml under
<ServerStart Arguments ClassPath>
Or under the console under Servers > Remote Start > Class Path (here you have to put the entire path and just append what you need to the end because it doesn't automatically append, it overwrites
Some of this may be intuitive but it was not to me and I am still working on the syntax for the path because it works in a startup script but not in the console or config file, go figure.
I am a little limited mentally though, so it would probably be a lot easier to someone else. :-)
Thanks for sharing.
I've had classpath problems too, so I guess it means we're both "challenged" ;-)
Quick question, I know if you load the classpath it reads classes in the WEB_INF/classes folder, but does it treat .jar files the same or do you have to reference them specifically? Of course, I mean in theory :-)
I am doing jasper reports... and want to call it from coldfusion and was wondering if I included the jasper .jar files if I would be able to point to WEB-INF/lib or if I have to have WEB-INF/lib/specific.jar
Thanks again for your help!
Yes, it should treat jar files the same way. ie. Just point it at WEB-INF/lib rather than individual jar files. At least that's been my experience :)
I am so glad to hear that... I will let you know one way or the other how it works out...