servlet-api-2.5.jar - jar not loaded - tomcat error
This is a common error you will see when you deploy your war file in tomcat.
Aug 13, 2013 6:15:26 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(E:\apache-tomcat-7.0.53\webapps\test\WEB-INF\lib\servlet-api-2.5.jar)
- jar not loaded.
See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
|
This error is occured because tomcat by default comes with servlet-api.jar file. Now your application also providing
servlet-api.jar file. There is a conflict for tomcat to pick the servlet-api.jar. The solution is very simple for this problem. In your
maven dependencies, you have specified servlet-api jar file. When maven bundles the war file, it includes all dependent jar files. You
configure your maven dependencies such a way that exclude this jar file during creation of war file. How can we exclude a jar file?
Possibly, this is how your dependency declaration in pom.xml file
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
|
Now add scope as provided to the above dependency. Which will include the jar till compilation only.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
|
|