Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid the error “javax.servlet-api-3.0.1.jar - jar not loaded”?

I am using Windows 7, Java 1.7, Grails 2.1.4, Groovy 2.0.4 and Tomcat 7.0.37.
When executing my project, I get the error below:

Apr 5, 2013 11:08:00 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
    INFO: validateJarFile(/software/apache-tomcat-7.0.37/webapps/aaaportal-0.1/WEB-INF/lib/javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    Apr 5, 2013 11:08:13 AM org.apache.catalina.loader.WebappClassLoader loadClass
    INFO: Illegal access: this web application instance has been stopped already.  Could not load org.bouncycastle.jce.provider.JDKKeyPairGenerator$RSABeanInfo.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
    java.lang.IllegalStateException
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1599)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
        at java.beans.Introspector.instantiate(Introspector.java:1444)
        at java.beans.Introspector.findExplicitBeanInfo(Introspector.java:428)
        at java.beans.Introspector.<init>(Introspector.java:377)
        at java.beans.Introspector.getBeanInfo(Introspector.java:164)
        at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:2948)

I tried different versions of servlet-api and bcprov-ext-jdk15-*.jar, but that didn't help.

Should I be worried about this error?
How can I get it to disappear?

like image 399
Sun Avatar asked Apr 07 '13 05:04

Sun


2 Answers

You simply have to use a provided scope for your dependency like the following:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>3.0.1</version>
  <scope>provided</scope>
</dependency> 

So it will not packaged in your WAR/EAR file anymore.

like image 154
khmarbaise Avatar answered Sep 20 '22 12:09

khmarbaise


The servlet-api jar shouldn't be in your WEB-INF/lib at all, as it is provided by the container. The warning message is quite explicit - the servlet spec requires containers to ignore any jar files in a webapp that contain javax.servlet classes. You can safely ignore that message.

The second message about bouncycastle is also probably not what it seems. There's probably been another error which caused the webapp not to start up correctly, and this message appears when something else tries to load a class from the already-shutdown webapp. Check your other log files, and possibly edit your log4j settings in Config.groovy to make the logging more verbose, and see if that shows the real underlying error.

like image 8
Ian Roberts Avatar answered Sep 18 '22 12:09

Ian Roberts