jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

后端 未结 12 639
有刺的猬
有刺的猬 2020-11-27 03:58

I am running a Maven project which is also a dynamic web project. I have used all Spring libraries in Maven. I created web.xml, but when I start my Tomcat 7 ser

12条回答
  •  失恋的感觉
    2020-11-27 04:49

    Typically when you see this message, it is benign. If it says

    INFO: validateJarFile(//WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. 
    See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    

    It means it is ignoring your servlet-api-2.5.jar because tomcat already has a built-in version of that jar, so it isn't going to be using yours. Typically this doesn't cause an issue.

    If however it says WEB-INF/lib/my_jar.jar - jar not loaded...Offending class: javax/servlet/Servlet.class

    then what you can do (in my instance, it's a shaded jar) is run

    $ mvn dependency:tree

    and discover that you have a transitive dependency on "something" that depends on a jar that is either servlet-api or something like it (ex: tomcat-servlet-api-9.0.0). So add an exclusion to that to your pom, ex: (in my case, tomcat, in your case, probably the ones mentioned in the other answers):

     
        ...
        
          
            org.apache.tomcat
            tomcat-servlet
          
         
    
    

提交回复
热议问题