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

后端 未结 12 592
有刺的猬
有刺的猬 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:24

    To fix it, set the scope to provided. This tells Maven use code servlet-api.jar for compiling and testing only, but NOT include it in the WAR file. The deployed container will “provide” the servlet-api.jar at runtime.

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    
    0 讨论(0)
  • 2020-11-27 04:26

    when your URL pattern is wrong, this error may be occurred.

    eg. If you wrote @WebServlet("login"), this error will be shown. The correct one is @WebServlet("/login").

    0 讨论(0)
  • 2020-11-27 04:30

    Check Inside the Following Directory for the jar file el-api.jar :C:\apache-tomcat-7.0.39\lib\el-api.jar if it exists then in this directory of your web application WEB-INF\lib\el-api.jar the jar should be removed

    0 讨论(0)
  • 2020-11-27 04:32

    Exclusions and provided dependencies will not work in child projects.

    If you are using inheritance in Maven projects you must include this configuration on the parent pom.xml file. You will have a <parent>...</parent> section in your pom.xml if you are using inheritance. So you will have something like this in your parent pom.xml:

    <groupId>some.groupId</groupId>
    <version>1.0</version>
    <artifactId>someArtifactId</artifactId>
    <packaging>pom</packaging>
    <modules>
        <module>child-module-1</module>
        <module>child-module-2</module>
    </modules>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    
    0 讨论(0)
  • 2020-11-27 04:34

    Maven Dependency Scope

    provided : This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

    0 讨论(0)
  • 2020-11-27 04:34

    The JAX-WS dependency library “jaxws-rt.jar” is missing.

    Go here http://jax-ws.java.net/. Download JAX-WS RI distribution. Unzip it and copy “jaxws-rt.jar” to Tomcat library folder “{$TOMCAT}/lib“. Restart Tomcat.

    0 讨论(0)
提交回复
热议问题