[Tomcat] validateJarFile(servlet-api.jar) - jar not loaded. Offending class: javax/servlet/Servlet.class - Digizol6

Post Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Thursday, July 9, 2009

[Tomcat] validateJarFile(servlet-api.jar) - jar not loaded. Offending class: javax/servlet/Servlet.class

validateJarFile jar not loadedorg.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(<APP_PATH>\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
.

We are using Apache Tomcat to deploy web applications, and getting the above message when Apache Tomcat is started. All web applications inside Tomcat are working fine, however no developer would want to see message (at least we do not want to see).

The above message is only a warning message due to the existence of multiples of the same javax.servler.Servlet.class for Tomcat runtime to pick; and this extra instance has come from a jar file named <APP_PATH>\WEB-INF\lib\servlet-api.jar. Tomcat has its own servlet-api.jar file; look at the following folders to locate the file (depending on the Tomcat version; location may be different).
  • <TOMCAT_HOME>\common\lib
  • <TOMCAT_HOME>\lib
Your web applications have the same servlet-api.jar file inside following folder.
  • <TOMCAT_HOME>\webapps\<PROJECT>\WEB-INF\lib
As the Tomcat runtime has the required javax/servlet/Servlet.class file loaded from its own lib\servlet-api.jar file, you do not need to place it inside each and every web application. After removing the jar file from your web application, you will not receive the message again.

Related Articles

14 comments:

  1. Thanks this helped me.

    ReplyDelete
  2. Helped me as well, many thanks! :)

    ReplyDelete
  3. After removing the jar file from my web application,it shows the same error-servet-api.jar not loaded....nw what i do

    ReplyDelete
  4. THANK YOU A LOT.... i removed that servelt-api.jar from my application and it worked!!!

    ReplyDelete
  5. Hi,
    I'd like to elaborate on that.

    Not only do you not need to, but you even must not add any version of the servlet API to your webapp.

    The servlet API and more important its implementation is provided by the servlet container, in your case Tomcat.

    Due to the way classloaders in a servlet/jee environment work, adding the servlet API to your JEE app can cause severe problems. In JEE environments the classloader hierarchy works different, as it FIRST looks in the webapp/ear for a class to load before referring to parent classloaders.

    Now imagine deploying your webapp on a servlet 2.4 compatible container having servlet api 2.5 in your classpath....

    In fact, Tomcat does not check whether the servlet api in your webapp matches the servlet api version of Tomcat. It always delegates to the parent classloader informing you about this severe misconfiguration. The same is true for all packages of the java.* namespace.

    ReplyDelete
  6. And another big thank you from here. Also kudos to dukeslittleb.

    ReplyDelete
  7. Thank you! It has helped me a lot!

    ReplyDelete
  8. Hi i have only one servlet.jar under my tomcat/common/lib directory in addition to tht while compiling the servlets i passed the servlet.jar file as part of the classpath still i seee tht error

    ReplyDelete
  9. I resolved the problem with removing the libraries from web-inf/lib as stated above and included log4j into the projects build path and imported one sample log4j.properties file into the project. thank you!

    ReplyDelete
  10. thanks,
    it helped me

    ReplyDelete
  11. hi
    as above u said i have done it but still my problem is stand
    what to do now because again my war file not work and error comes again and again.
    thanks in advance.
    plz tell me on joanthonipandu@rediffmail.com

    ReplyDelete
  12. Thanks a lot,
    This amazing Tip worked for me too

    ReplyDelete

Post Top Ad

Responsive Ads Here