• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

class file location

New Here ,
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

I am not sure if this would be an admin type question but here goes:
I have a Coldfusion 6.1 server riding on Weblogic 8 ish and I am trying to do a small java example... *sigh*
I am getting a "class not found" error and so I went looking for my classpath, since it didn't seem to be what was default in the documentation. *sigh*
So I find that it is defaulting to .jar files and no directories. I can see that there are class files that are out in our coldfusion land so how does it see these? I am pretty ignorant of weblogic. I was curious how they can be reading the files, if they are, when the paths that I see only point to jar files. So, no explanation is too simple, please use small words and type slow for me. How should/do I change the path since I have to change it in Weblogic not CF admin. Is there some kind of default folder I am missing? I even tried adding my class to cfclasses under the cf file directory. Any help (and I need a lot) would be greatly appreciated.

Thank you in advance for your infinite patience and any help you can provide!!!
~Va 🙂
TOPICS
Advanced techniques

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

(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

http://www.adobe.com/support/coldfusion/j2ee/cfmx7j2ee_weblogic_deploy.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

Additional info: Even though the tech note is for cfmx 7, it should still give you some useful information.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

>> 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.

http://livedocs.adobe.com/coldfusion/7/htmldocs/00001561.htm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

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....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

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 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

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.

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

Wish I knew more about weblogic paths. Out of curiousity, did you try adding a jar file to the "lib" directory?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

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,
Va.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 07, 2007 Jun 07, 2007

Copy link to clipboard

Copied

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;

package ironyx;

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--->
<cfset mySimpleMath.init()>

<!--- 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 08, 2007 Jun 08, 2007

Copy link to clipboard

Copied

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!!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 08, 2007 Jun 08, 2007

Copy link to clipboard

Copied

>>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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 08, 2007 Jun 08, 2007

Copy link to clipboard

Copied

>>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 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2007 Jun 11, 2007

Copy link to clipboard

Copied

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. 🙂

Take care,
Va.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 11, 2007 Jun 11, 2007

Copy link to clipboard

Copied

Thanks for sharing.

I've had classpath problems too, so I guess it means we're both "challenged" 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 12, 2007 Jun 12, 2007

Copy link to clipboard

Copied

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!
Va. 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 12, 2007 Jun 12, 2007

Copy link to clipboard

Copied

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 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 12, 2007 Jun 12, 2007

Copy link to clipboard

Copied

LATEST
I am so glad to hear that... I will let you know one way or the other how it works out...

Thanks!
Va.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation