• Post Reply Bookmark Topic Watch Topic
  • New Topic

WRONG CLASS FILE WHEN COMPILING JSP  RSS feed

 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

When compiling a JSP page, I am getting the following error:

----------------

C:\Program Files\Apache\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\...(JSP FILE NAME HERE)
cannot access java.lang.Object
bad class file: C:\Program Files\Java\jre1.5.0\lib\rt.jar(java/lang/Object.class)
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

-----------------

I see that a lot of people have posted messages on various Websites with no answers.

Has anybody seen this issue?

I'm using 5.0 of Tomcat for JDK and JRE. My Java_HOMe variable points to the correct 5.0 directory.

Please help!!!

Thanks.

- Mike
 
Logan Owen
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how to get around this...but doing some research...it sounds like your compile time and run time JVM versions are different. 49.0 refers to J2SE 5.0, while 48.0 refers to JDK 1.4. Possibly you need to set the PATH system variable differently, so that it will only see J2SE 5.0 virtual machines?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most recent versions of Tomcat no longer use javac from the JDK to compile JSPs, but rather they use some version of the Eclipse JDT compiler. It may be that this Eclipse compiler is a version that doesn't handle JDK 1.5 at all. Not sure how to confirm if this is the problem, or if it's simply a multiple-JDK problem.
 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

Here's the error from the Tomcat Log (You'll see that it's complaining about RT.JAR):

cannot access java.lang.Object
bad class file: C:\Program Files\Java\jre1.5.0\lib\rt.jar(java/lang/Object.class)
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

If your theory is correct, then Tomcat is confused.

Except that I only have *one* JDK on my computer (1.5.0 b64) now and I'm still getting the error.

???

This is strange.

Hopefully, somebody has seen this error.

Thanks again.

-- Mike
 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,

I'm currently using Tomcat 5.0.18.

Is this a possible candiate for the problem you described?

Thanks.

-- Mike
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike London:

I'm currently using Tomcat 5.0.18.


I think it only applies to 5.5 and later.

Can you use Windows "Find File" to search for tools.jar? That would be where the old compiler lives. Maybe you've got a stray tools.jar someplace.
 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,

THANK YOU!!!

Yes, the culprit was tools.jar in the Tomcat\common\libs folder. Apparently, it didn't get updated when I moved to Tomcat 5, but most JSPs were working OK so I didn't notice.

Do you think it's worthwhile moving to 5.5?

It's a major pain updating Tomcat, unless I'm missing something, since as I understand it, you have to install it to a new subdirectory, fix the config files, copy all your stuff over, and test ... test ... test.

Is there an easier way to update Tomcat? For example, can you just install it in the same directory where a previous 5.0 version was installed?

I tried to install Tomcat 5.4, but it died on the line where it was trying to install the Windows service. I had stopped the Tomcat 5.0.18 service, but didn't uninstall it.

These complications keep me from upgrading all that often...

Look forward to your reply....Thanks!!!

-- Mike
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you'd only notice when it needed to compile a JSP, anything compiled before installing JDK 1.5 would not get the compiler to be launched.

Just replace the tools.jar with the one from the JDK 1.5 installation and things should work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!