0

Basically I'm not able to overcome this error, trying time and again.

I have ported my current javaee project to maven, made a war from maven 3.0.3, which doesnt seem to deploy in tomcat 6.0.10.I am using jdk 1.7 (though, i get the same error using jdk 1.6 and tomcat 7)

The error it throws is

Mar 15, 2013 10:24:39 AM org.apache.catalina.loader.WebappClassLoader validateJa
rFile
INFO: validateJarFile(D:\apache-tomcat-6.0.10\webapps\Name\WEB-INF\lib\
javaee-api-5.0-1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Off
ending class: javax/servlet/Servlet.class
Mar 15, 2013 10:24:39 AM org.apache.catalina.loader.WebappClassLoader validateJa
rFile
INFO: validateJarFile(D:\apache-tomcat-6.0.10\webapps\Name\WEB-INF\lib\
servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offe
nding class: javax/servlet/Servlet.class
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail
s.
Inside Cache Manager Initialization new ....
java.lang.NullPointerException
Mar 15, 2013 10:24:59 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 15, 2013 10:24:59 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Name] startup failed due to previous errors

When i tried to find out about the error "jar not loaded. See Servlet Spec 2.3, section 9.7.2", it said that the preferred jar must be present at both copilation and runtime, so i added servlet-api-2.5.jar inside the pom.xml. javaee-api-5.0.1.jar was already there.

After adding the dependency, i get the same error.

Anyone got any idea about this weird behaviour.

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
  • possible duplicate of [Error: Servlet Jar not Loaded... Offending class: javax/servlet/Servlet.class](http://stackoverflow.com/questions/1993493/error-servlet-jar-not-loaded-offending-class-javax-servlet-servlet-class) – Raedwald Feb 13 '15 at 13:13

2 Answers2

3

Change the scope of servlet api to <scope>provided</scope> since it is provided by tomcat. And javaee-api is NOT provided by tomcat, so keep it in your webapp.

Tomcat doesn't support the full Java EE stack, but only part of it (i.e. servlet-api is supported, but JTA, JPA, JMS aren't supported): that's why you need to include javaee-api in your web-app

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
ben75
  • 29,217
  • 10
  • 88
  • 134
  • Do all Java EE features work in Tomcat just by adding that dependency? No need to use TomEE? – Panu Haaramo Feb 19 '18 at 09:58
  • 1
    @PanuHaaramo No. Tomcat have an implementation of servlet-API embedded, but no implementation for JTA, JPA, JMS, ... so to use them with tomcat you must explicitly add your favorite implementation of those specs in the classpath. – ben75 Feb 19 '18 at 12:16
1

The "jar not loaded" errors are caused by having multiples of javax/servlet/Servlet.class for the Tomcat runtime to choose from. Remove javaee-api-5.0-1.jar and servlet-api-2.5.jar from your app's WEB-INF/lib. These jars are already provided by Tomcat. To verify this look in <TOMCAT_HOME>\lib to see that these jars are already there.

Jake Stoeffler
  • 2,662
  • 24
  • 27
  • servlet-api-2.5.jar was present, removed it but javaee-api-5.0-1.jar was not there, so I m still stuck. Does tomcat has any lib which has its dependecy on javaee-api jar ? – ItachiUchiha Mar 15 '13 at 09:05
  • `javaee-api-5.0.1.jar` was not where? In `/lib`? Try removing it from `WEB-INF/lib` anyway and see what happens. – Jake Stoeffler Mar 15 '13 at 17:31