File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes javax.servlet.ServletException: Error allocating a servlet instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "javax.servlet.ServletException: Error allocating a servlet instance " Watch "javax.servlet.ServletException: Error allocating a servlet instance " New topic
Author

javax.servlet.ServletException: Error allocating a servlet instance

Ajay Njallacattu
Ranch Hand

Joined: Nov 21, 2006
Posts: 39
Hi,

We are getting the following exception when we try to run a web application in Apache Tomcat.

javax.servlet.ServletException: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:595)
root cause

java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1815)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:869)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1322)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:595)

Regards
Ajay
Jeff Ishar
Greenhorn

Joined: Jul 04, 2011
Posts: 13


This is due to difference between JDK versions, the java source was compiled with other JDK version then tomcat is running on. Try to match the JDK version on both server and development machine (where classes are generated). Once tomcat try to load the servlet class with classloader from JDK 6 (for ex) but the classes were compile with JDK 5, it will through the above exception and after that the rest of exception will be thrown.



Hope this helps
Ajay Njallacattu
Ranch Hand

Joined: Nov 21, 2006
Posts: 39
Hi,

We have matched the JDK for the development and deployment. Still we are getting the same issue.

Is there anything else we need to do get this working?


Regards

Ajay
Jeff Ishar
Greenhorn

Joined: Jul 04, 2011
Posts: 13
After matching the JDK, did you recompile the classes and build the war file and redeploy it ? Restart the tomcat? What version you are running the server on?

thanks
Ajay Njallacattu
Ranch Hand

Joined: Nov 21, 2006
Posts: 39
All,

The issue was with respect to the different JDK versions.

Thanks a lot for all the inputs..


Regards

Ajay
 
Don't get me started about those stupid light bulbs.
 
subject: javax.servlet.ServletException: Error allocating a servlet instance
 
Similar Threads
Servlet not available?
Error allocating a servlet instance.
servlet exception!!!!
servlet exception
Error allocating a servlet instance