Abstract: How do I resolve a java.lang.UnsupportedClassVersionError?
Issue:
When I attempt to run my Servlet, I receive the following exceptions:
javax.servlet.ServletException: Error allocating a servlet instance
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:185)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:653)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:534)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.java:403)
com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)root cause java.lang.UnsupportedClassVersionError: untitled1/Servlet1 (Unsupported major.minor version 49.0)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:537)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1774)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:905)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1370)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1234)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:185)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:653)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:534)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.java:403)
com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)How do I resolve this issue?
Solution:
--------------------------------------------------------------------------------------------------This exception can occur when the source is built targeting a JDK that is not supported by the JDK attempting to run it. In the above example, if the servlet was built targeting only JDK 1.5, but the web server runs JDK 1.4, the above exception will occur.
Check, Project Properties | Build | Java | Target VM, and verify that the Target VM indicates a JDK compatibility that is appropriate for the JDK that is running it. It is recommended to set this field to 'All Java SDKs' for the most compatibility. The only reason you would want to specify a particular version is if your code uses language features that only appear in a particular verison of the JDK, and you want to ensure that users use only a compatible JDK.
Also check, Project Properties | Build | Java | Language Features, and verify that the Language Features are applicable with JDK that is running it.
java.lang
Class UnsupportedClassVersionError
java.lang.Object java.lang.Throwable java.lang.Error java.lang.LinkageError java.lang.ClassFormatError java.lang.UnsupportedClassVersionError
- All Implemented Interfaces:
- Serializable
- public class UnsupportedClassVersionError
- extends ClassFormatError
Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported.
- Since:
- 1.2
- See Also:
- Serialized Form
Constructor Summary | |
UnsupportedClassVersionError() Constructs a UnsupportedClassVersionError with no detail message. | |
UnsupportedClassVersionError(String s) Constructs a UnsupportedClassVersionError with the specified detail message. |
Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
UnsupportedClassVersionError
public UnsupportedClassVersionError()
- Constructs a
UnsupportedClassVersionError
with no detail message.
UnsupportedClassVersionError
public UnsupportedClassVersionError(String s)
- Constructs a
UnsupportedClassVersionError
with the specified detail message. - Parameters:
s
- the detail message.
|
JavaTM 2 Platform Std. Ed. v1.4.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
-------------------------------------------------------------------------
java.lang.UnsupportedClassVersionError
|