java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter when starting Simple Struts2 Application

后端 未结 3 1483
醉酒成梦
醉酒成梦 2020-11-27 22:05

I am trying to run a simple Struts2 application but it always throw the following exception:

java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.         


        
相关标签:
3条回答
  • 2020-11-27 22:43

    I think you specified like this

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>X.X.X.X</version>
    </dependency>
    

    try to add

    <dependency>
         <groupId>org.apache.struts</groupId>
         <artifactId>struts2-core</artifactId>
         <version>2.1.6</version>
        </dependency>
    
    0 讨论(0)
  • 2020-11-27 22:47

    Use this command to convert Maven project to Dynamic Web Project for Eclipse:

    mvn eclipse:eclipse -Dwtpversion=3.4.2
    

    you may change whatever WTP version you use

    .classpath should be like this

    <classpath>
      <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
      <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
      <classpathentry kind="output" path="target/classes"/>
      <classpathentry kind="var" path="M2_REPO/asm/asm/3.3/asm-3.3.jar"/>
      <classpathentry kind="var" path="M2_REPO/asm/asm-commons/3.3/asm-commons-3.3.jar"/>
      <classpathentry kind="var" path="M2_REPO/asm/asm-tree/3.3/asm-tree-3.3.jar"/>
      <classpathentry kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2.jar" />
      <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/2.0.1/commons-io-2.0.1.jar"/>
      <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5.jar"/>
      <classpathentry kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.18/freemarker-2.3.18.jar"/>
      <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar"/>
      <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
      <classpathentry kind="var" path="M2_REPO/ognl/ognl/3.0.4/ognl-3.0.4.jar"/>
      <classpathentry kind="var" path="M2_REPO/org/apache/struts/struts2-core/2.3.1.2/struts2-core-2.3.1.2.jar"/>
      <classpathentry kind="lib" path="C:/Program Files/Java/jdk1.6.0_32/lib/tools.jar"/>
      <classpathentry kind="var" path="M2_REPO/org/apache/struts/xwork/xwork-core/2.3.1.2/xwork-core-2.3.1.2.jar"/>
      <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    </classpath>
    

    After build the WAR file should deploy to %CATALINA_BASE%\webapps.

    0 讨论(0)
  • 2020-11-27 22:53

    Dear this the part of Struts 2 Core 2.2.3.1 API.

    And I tried to run you linked project it is properly working for me. there is no issue.

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