Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

Posted on 2001-09-06
Medium Priority
280 Views
I am trying to run a simple chat program.  This program is from Oreilly.com.  Anyway, the problem seems to be a classpath problem.

I am using apache/tomcat.  On my work computer, Windows NT 4.0 this program works great!!  Same exact setup of apache/tomcat.  At home, on windows 98 I have multiple problems.

First, I am using a package "com.oreilly.servlet.*".  This package is loaded by a jar file "cos.jar".  On my windows nt machine, I changed the <control panel><system><classpath> to include "c:/jdk1.3/lib/cos.jar".  This machine executes the program fine.

At home, on windows 98, I changed my autoexec.bat file to point to this package:
SET CLASSPATH="c:\jdk1.3\lib";"C:\jdk1.3\lib\cos.jar";

I also have included the following statement in my Tomcat startup file "startup.bat":

SET JAVA_HOME=C:\JDK1.3
SET TOMCAT_HOME=C:\apache\tomcat
SET PATH=%PATH%;C:\JDK1.3\BIN
SET CLASSPATH=%PATH%;c:\jdk1.3\lib;c:\jdk1.3\lib\cos.jar;

Yet, when I execute this chat program from my windows 98 machine, I get the following message:

General exception: java.lang.ClassNotFoundException: com.oreilly.servlet.HttpMessage

It seems to me that for some reason, tomcat is not recognizing the com.oreilly jar file (cos.jar) on my windows 98 machine.  Yet it does on my NT machine.

Please, provide any insight you can provide.

Thanks,
JDC
0
Question by:jdc0724
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions
• 13
• 8
• 3
• +1

LVL 92

Expert Comment

ID: 6462944
> SET CLASSPATH=%PATH%;c:\jdk1.3\lib;c:\jdk1.3\lib\cos.jar;

Is %PATH% a type?
Should be %CLASSPATH%

Also you should put your jars in c:\jdk1.3\lib\ext, instead of c:\jdk1.3\lib.
That way you don't even need to include them in your classpath, they get picked up automatically.
0

LVL 1

Author Comment

ID: 6462989
I have put most of my extension in c:\jdk1.3\lib\ext but when I included the "com.oreilly.servlet.*" package in it didn't seem to work unless I actually specified the full path to the cos.jar file in my autoexec.bat.  I thought I would be able to just specify a direcotory of the jdk (ie: lib\ext) and then it would pick up all the .jar files automatically.

The line of code you were questioning above:
SET CLASSPATH=%PATH%;c:\jdk1.3\lib;c:\jdk1.3\lib\cos.jar

was a line I just added to try to get my stuff to work.  The setup I have on windows NT 4.0 dosen't have this line of code in my Tomcat startup.bat file and it seems to work. The other three lines of code:

SET JAVA_HOME=C:\JDK1.3
SET TOMCAT_HOME=C:\apache\tomcat
SET PATH=%PATH%;C:\JDK1.3\BIN

are in the tomcat startup.bat file on my Windows NT 4.0 machine, and like I said they work fine. Not sure what is going on with my Win98 machine.  They have the same exact setup for apache/tomcat.

I can work all night on my win98 machine, have it load the chat applet,and when you type in a message you get the "class not found" error.  Yet I take the same class files from my win98 machine, put them on my NT machine and they will generally work!!!

HELP!!!  This must be something simple.

Thanks,
JDC
0

LVL 92

Expert Comment

ID: 6463003
Try putting the jar in c:\apache\tomcat\lib
0

LVL 1

Author Comment

ID: 6463009
Yup, did that.  Rebooted.  Nothing has changed.  Still dosen't recognize the package.
0

LVL 1

Author Comment

ID: 6463026
Also, curious why jars in c:/jdk1.3/jre/lib get picked up automatically.  I have had problems including just the path to directories that contain jar files.  Most of the time I have to include the absolute path to each jar file.
0

LVL 92

Expert Comment

ID: 6463048
> Also, curious why jars in c:/jdk1.3/jre/lib get picked up automatically

It doesn't.
c:/jdk1.3/jre/lib/ext does.

> I have had problems including just the path to
> directories that contain jar files

This won't work. You have to include the complete jar apth.

0

Expert Comment

ID: 6463069
Try changing this:
SET CLASSPATH=%PATH%;c:\jdk1.3\lib;c:\jdk1.3\lib\cos.jar

to:
SET CLASSPATH=%CLASSPATH%;c:\jdk1.3\lib;c:\jdk1.3\lib\cos.jar

Also, how exactly does Apache start tomcat? Does it use one of the batch files available in the bin directory of tomcat. Which bat file? A look at that file will reveal the problem.
0

LVL 1

Author Comment

ID: 6463942
Apache dosen't actually start tomcat.  I use a batch file (included with tomcat) to start tomcat.  I was thinking the same thing about the batch files being the problem....  So I came into work last night, made a copy of the tomcat startup.bat file that I use on my NT machine (which is also the machine where my chat application runs), and brought it home.

I then put the startup.bat file from my NT machine on my 98 machine, rebooted and yet I still get a class not found error (for my cos.jar file) when I try to execute a servlet that imports a class from that jar.
0

LVL 13

Expert Comment

ID: 6463971
What does tomcat say it is using as the classpath? Is the oreilly jar in it?
Have you checked the jar to see if this class is indeed in it?
0

LVL 1

Author Comment

ID: 6464071
at first the oreilly jar was not included in the tomcat classpath.  But before I called it quits last night I finally had it including the path.  I use the following set statements in my tomcat startup.bat file.  (these are the exact same statements I use on my NT machine which works fine):

SET JAVA_HOME=C:\JDK1.3
SET TOMCAT_HOME=C:\apache\tomcat
SET PATH=%PATH%;C:\JDK1.3\BIN
0

LVL 13

Expert Comment

ID: 6464100
So even when tomcat says "using classpath ..." that includes the oreilly jar the class is still not found ?

Have you checked the jar to see if this class is indeed in it?
0

LVL 1

Author Comment

ID: 6464152
Yes, at least I believe so.  It was late but I am positive that I somehow got tomcat to include the jar file.  I am also positive that the class is in it.  I am going to run home in a couple of hours and try it again.  I am not really sure why we set PATH not CLASSPATH in the startup.bat file.  But that was the instructions I was given, and this works on all the computers here at work (including my NT machine).

I just tried moving the jar file into my jdk1.3/jre/lib/ext, removed my classpath statement pointing to the jar file (on my NT machine) and "objects" was right...  I didn't need to include this jar in my classpath.  It was picked up automatically.  This might be the approach I take on my 98 machine in a couple of hours.  I must be setting the path wrong somewhere.  It is all I can come up with.
0

LVL 13

Expert Comment

ID: 6464186
I remember I had a lot more classpath problems on Win98 than I've ever had on NT.

As the answers to my last two question are that tomcat is using the correct classpath and the class is in the jar, I am a bit stumped.

Let us know your progress and I'll try to remember my specific problems and their fixes.
0

LVL 1

Author Comment

ID: 6464232
I'll do that.  after lunch sometime I should know more.  I want to double check the settings I put in place last night.
0

LVL 1

Author Comment

ID: 6464692
Now I am having the same problem on my NT machine.  This is all I have done today that might have caused the error...

1. I removed cos.jar from c:\jdk1.3\lib and placed it in c:\jdk1.3\jre\lib\ext.
2. Since I moved the cos.jar file to this directory (objects said this would get picked up automatically), I removed this entry from my classpath C:/jdk1.3/lib/cos.jar.

Thats all I did.  And, even with these changes I can compile just fine.  However, I am getting the same "httpmessage class not found" error when I run the application!

Any thoughts?

JDC
0

LVL 1

Author Comment

ID: 6465257
Well, i moved the cos.jar file back into the c:\jdk1.3\lib directory and changed my classpath back and it works on my NT machine now.  I liked the idea of having it in the c:\jdk1.3\jre\lib\ext directory but I guess that dosen't work for this jar file.  Not sure why.

Anyway, I checked my 98 machine.  Tomcat has included the cos.jar file in its classpath and it still dosen't work.  Not sure why.  I will have to research further.

JDC
0

LVL 92

Expert Comment

ID: 6465820
It may be that Tomcat does not automatically pick things up in the ext directorry.
I think the $TOMCAT_HOME/lib is used by tomcat in a similiar way, ie. jars in there are added to classpath automatically. 0 LVL 92 Expert Comment ID: 6465825 May be worth doing some experimenting with a different jar and see if it gets loaded ok by tomcat on win98. That'll at least tell you if it's a particulat problem with cos.jar or a general win98 problem. 0 LVL 92 Expert Comment ID: 6465828 What else is in that strtup bat? 0 LVL 1 Author Comment ID: 6466195 I am going to include both of the tomcat startup files that I have. First, I will show the one I have on my NT machine and everything works fine. I tried using this one on my 98 machine but I still have the same problem. Here are the contents of the files: NT Machine startup file: @echo off rem$Id: startup.bat,v 1.7.4.1 2000/09/04 21:18:05 larryi Exp $rem Startup batch file for tomcat servner. rem This batch file written and tested under Windows NT rem Improvements to this file are welcome rem *==== placed here by Joshua Carey to correct issue when starting tomcat ===* SET JAVA_HOME=C:\JDK1.3 SET TOMCAT_HOME=C:\apache\tomcat SET PATH=%PATH%;C:\JDK1.3\BIN rem SET CLASSPATH=%CLASSPATH%;c:\jdk1.3\lib;c:\jdk1.3\lib\cos.jar rem *==== End of set statements by Joshua Carey =======* if not "%TOMCAT_HOME%" == "" goto start SET TOMCAT_HOME=. if exist "%TOMCAT_HOME%\bin\tomcat.bat" goto start SET TOMCAT_HOME=.. if exist "%TOMCAT_HOME%\bin\tomcat.bat" goto start SET TOMCAT_HOME= echo Unable to determine the value of TOMCAT_HOME. goto eof :start call "%TOMCAT_HOME%\bin\tomcat" start %1 %2 %3 %4 %5 %6 %7 %8 %9 :eof Here was the original tomcat startup.bat file from my 98 machine: @echo off rem$Id: startup.bat,v 1.7.4.1 2000/09/04 21:18:05 larryi Exp \$
rem Startup batch file for tomcat servner.

rem This batch file written and tested under Windows NT
rem Improvements to this file are welcome

rem --- Placed here by Joshua Carey to correct issue when starting tomcat
set TOMCAT_HOME=C:\apache\tomcat

if not "%TOMCAT_HOME%" == "" goto start

SET TOMCAT_HOME=.
if exist "%TOMCAT_HOME%\bin\tomcat.bat" goto start

SET TOMCAT_HOME=..
if exist "%TOMCAT_HOME%\bin\tomcat.bat" goto start

SET TOMCAT_HOME=
echo Unable to determine the value of TOMCAT_HOME.
goto eof

:start
call "%TOMCAT_HOME%\bin\tomcat" start %1 %2 %3 %4 %5 %6 %7 %8 %9

:eof

I am going to mess around with the cos.jar file a little more.  Maybe it has to be placed in the jdk1.3/lib directory for it to work.  Like, I said earlier, on my NT machine, I placed the file in the c:/jdk1.3/jre/lib/ext and it did pick it up automatically.  Everything would compile just fine.  But when it came time to run the programs they no longer would run.  And this was on the NT machine where they have been running fine.  Long story short, I changed it back to the original setup and it started working again...
0

LVL 1

Author Comment

ID: 6471914
Ok, I am at wits end with this one.  I have (i think) determined that the only way the cos.jar file will work is in the c:/jdk1.3/lib directory.  Anywhere else and the programs will not run.  I am also at the determination that Windows 98 cannot resolve the classpath properly.  I have no problems with my NT machine.  On my 98 machine, I have tried everything.  I have made sure that Tomcat has resolved the appropriate classpath to the cos.jar file.  I have even had it resolve the file on my local filesystem as well as the filesystem that Tomcat loads jar files from by default.  Even with tomcat recognizing the cos.jar file, it will not run the programs appropriately.

Unless, anyone has any other suggestions, I would like to close this question.  Not sure what the best way to close this question since it has not been resolved??  Any ideas??  I would like to award the points to objects for the help and offer my thanks to everyone else.  How can I award the points without saying the question is answered?

Thanks again...  Goodbye windows 98!!!
0

LVL 92

Accepted Solution

objects earned 200 total points
ID: 6472453
> the only way the cos.jar file will work is in the c:/jdk1.3/lib directory

I find this very strange, where a jar is located should have no bearing on it's loading (as long as it's in the classpath of course).

Did you try loading a different jar with win98 to see if the problem was specific to cos.jar or not?

One other thing to try would be to unjar cos.jar and include resulting directory in your classpath.

0

LVL 1

Author Comment

ID: 6476658
I didn't try loading a different jar because I didn't have one.  I did however try many tests with the cos.jar file.  I agree it seems strange.  I put the jar file in jdk1.3/jre/lib/ext and even included that path in my classpath (even though I didn't need to since it got picked up there automatically).  When I did this, I could compile just fine.  However, at run time, it would not find any of the classes.   I verified that tomcat did indeed have the jar file in its classpath and yet it just wouldn't work.  I put the jar back into jdk1.3, changed my classpath back, and it worked fine.  KEEP in mind that everything I explained above was on my NT machine which is the only machine  I have gotten this to run.  On my win98 machine it has never worked.  Same programs, same version of apache/tomcat, same startup.bat files, etc.

If you would like to try this .jar file and see if I missed something obvious, then it can be found (along with the associated programs I am trying to run) at http://examples.oreilly.com/jservlet2/.  You can download this for free and it should only take a few minutes to set it up.  I think it would be worthwhile.

Thanks,
JDC
0

LVL 1

Author Comment

ID: 6632022
Even though I never got to the root of the problem, it seems to be a Win98 problem.  I changed to Win2000 and everything work great, as it did on NT also.  The only OS I couldn't get it to work with was 98.  Objects provided me with many helpful pieces of advice and it is appreciated.
0

LVL 92

Expert Comment

ID: 6633138
Anytime :)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
###### Suggested Courses
Course of the Month7 days, 10 hours left to enroll

#### 715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.