NoClassDefFoundError in web application running on Tomcat 7

前端 未结 4 418
面向向阳花
面向向阳花 2021-01-02 12:46

I have web application written in Java using gucie-servlet framework being built by Maven 3. When I deploy it on Tomcat 7 container and try to access it using browser, Tomca

相关标签:
4条回答
  • 2021-01-02 12:57

    I have resolved this issue by adding the Tomcat Server into the Java Build Path in eclipse.

    Right click on the project -> Build Path -> Configure Build Path -> Add library..(appears on the right side of the dialog box) -> Server Runtime -> Select "Apache Tomcat v.." -> Finish

    Then run the project on the server.

    0 讨论(0)
  • 2021-01-02 13:05

    Copy the files

    • com.sodius.mdw.core.jar
    • org.eclipse.emf.common.*version_name.jar
    • org.eclipse.emf.ecore.**.jar
    • org.eclipse.emf.ecore.xmi_2.9.1.v20130827-0309.jar

    in your ServletProjectName/WebContent/Web-INF/lib

    0 讨论(0)
  • 2021-01-02 13:08

    OK, I've found the solution. After careful study of my <TOMCAT_HOME>/logs/catalina.log I've found this record:

    Apr 5, 2013 1:38:26 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
    INFO: validateJarFile(/home/frodo/apache-tomcat-7.0.37/webapps/hive/WEB-INF/lib/base-0.0.42-SNAPSHOT.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    

    This question explains the reason of this message - my JAR base-0.0.42-SNAPSHOT.jar contains something related to Servlet API and can't be loaded by Tomcat because of it. So, my web app can't find classes in this JAR after start. I'm using some parts of Twitter commons inside this JAR which contain realization of Servlet API. After revision of the dependencies of base-0.0.42-SNAPSHOT.jar my app starts and loads classes needed. Thank you to everyone!

    0 讨论(0)
  • 2021-01-02 13:16

    The root cause may be the maven-war-plugin has been configured as the

    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <classpathPrefix>lib/</classpathPrefix>
            </manifest>
        </archive>
    </configuration>
    

    The above configuration is for Creating Skinny WARs which refers all war libs to the ear/lib instead.

    Please try to remove all of them from the maven-war-plugin configuration. Then build and deploy to the Tomcat again.

    I hope this may help.

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