JAVA EXAMPLE PROGRAMS

JAVA EXAMPLE PROGRAMS

Publish Your Article Here

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>

Java problems and solutions

  1. Unable to install Java 7 in Eclipse on Mac - Java 7 Mac OS issues
  2. How to change Java (JVM) version in Mac OS? - Java version Mac OS issues
  3. SunCertPathBuilderException: Unable To Find Valid Certification Path To Requested Target
  4. How to merge two jssecacerts files? - Merge key store files
  5. How to write Micro-Benchmark for java Hotspot?
  6. servlet-api-2.5.jar - jar not loaded - tomcat error
  7. How to exclude property files in a jar using Maven
  8. ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
  9. CGLIB is required to process @Configuration classes
  10. Git command to list conflicted files
  11. Where is default localhost folder in Mac OSX?
  12. How to edit hosts file on Mac OSX
  13. How to set up java version in Maven based projects?
  14. How to split a string by new line character in java?
Knowledge Centre
What is servlet context?
The servlet context is an interface which helps to communicate with other servlets. It contains information about the Web application and container. It is kind of application environment. Using the context, a servlet can obtain URL references to resources, and store attributes that other servlets in the context can use.
Famous Quotations
You can never get enough of what you don’t really need.
-- Eric Hoffer

About Author

I'm Nataraja Gootooru, programmer by profession and passionate about technologies. All examples given here are as simple as possible to help beginners. The source code is compiled and tested in my dev environment.

If you come across any mistakes or bugs, please email me to [email protected] or you can comment on the page.

Most Visited Pages

Other Interesting Sites

Reference: Java™ Platform Standard Ed. 7 - API Specification | Java is registered trademark of Oracle.
Privacy Policy | Copyright © 2017 by Nataraja Gootooru. All Rights Reserved.