Bug 44633 - say which jar/class is wrong when throwing UnsupportedClassVersionError
Summary: say which jar/class is wrong when throwing UnsupportedClassVersionError
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 6.0.16
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2008-03-19 08:25 UTC by Ralf Hauser
Modified: 2008-04-15 06:49 UTC (History)
0 users

Lsjar.java (15.57 KB, text/x-java)
2008-03-24 01:15 UTC, Ralf Hauser
Lsjar2.java (17.32 KB, patch)
2008-04-15 06:47 UTC, Arnaud Jotterand
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Hauser 2008-03-19 08:25:39 UTC
after happily using tomcat 6/java6, we had to move back to tomcat 5/java5. 

Unfortunately, it seems that one jar or .class files not yet compiled under java5 got there too.


in  at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1815)

catch UnsupportedClassVersionError and re-throw it after adding hints with which class sought/jar file it happens!

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1815)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:869)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1322)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
        at org.apache.catalina.core.StandardWrapper$1.run(StandardWrapper.java:1017)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1013)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        ... 6 more
Comment 1 Ralf Hauser 2008-03-24 01:15:41 UTC
Created attachment 21704 [details]

this is an approach to determine whether your jar files are the culprits

so, if there is java5 the requirement, you shouldn't see a major of 50

java -jar lsjar.jar -dir -jvmVersion /usr/share/tomcat/shared/lib/ | grep -v 48 | grep -v 46 | grep -v 49 | grep -v 47 | grep -v 45


in my case, they aren't  :(
Comment 2 Mark Thomas 2008-03-24 08:59:13 UTC
I have patched trunk and proposed it for inclusion in 6.0.x
Comment 3 Mark Thomas 2008-04-05 11:32:19 UTC
This has been fixed in 6.0.x and will be in the 6.0.17 onwards.
Comment 4 Arnaud Jotterand 2008-04-15 06:47:29 UTC
Created attachment 21822 [details]

Some class files of a jar may not have been compiled with the same version of Java than the others. It therefore may be useful to check the version of each class file contained in a jar.
Comment 5 Arnaud Jotterand 2008-04-15 06:49:27 UTC
Comment on attachment 21822 [details]

Added an -all option to Lsjar.java that allow to check every class file in a jar.