java.lang.ClassNotFoundException:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter启动简单struts2应用程序时
我试图运行一个简单的Struts2应用程序,但它总是引发以下异常:java.lang.ClassNotFoundException:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter启动简单struts2应用程序时,java,eclipse,maven,tomcat,struts2,Java,Eclipse,Maven,Tomcat,Struts2,我试图运行一个简单的Struts2应用程序,但它总是引发以下异常: java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 我已经遵循了中的逐步教程,但我无法使其工作 我还找到了其他使用maven的Struts2教程,但都失败了。当我尝试运行应用程序时,它会引发相同的异常 我使用了以下方法: 蚀 马文 雄猫 支柱2 根据其他讨论,依赖项ja
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
我已经遵循了中的逐步教程,但我无法使其工作
我还找到了其他使用maven的Struts2教程,但都失败了。当我尝试运行应用程序时,它会引发相同的异常
我使用了以下方法:
- 蚀
- 马文
- 雄猫
- 支柱2
web.xml
:
基本结构2
index.jsp
支柱2
org.apache.struts2.dispatcher.ng.filter.strutspreadexecutefilter
支柱2
/*
pom.xml
:
4.0.0
在…岗位上工作
基本结构2\u Mvn
战争
0.0.1-快照
基本支柱2
UTF-8
基本结构2\u Mvn
org.apache.maven.plugins
maven编译器插件
2.3.2
1.6
1.6
org.apache.struts
struts2型芯
2.3.1.2
log4j
log4j
1.2.14
struts.xml
:
/index.jsp
.classpath
:
我想你是这样指定的
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>X.X.X.X</version>
</dependency>
<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>
org.apache.struts
struts2型芯
X.X.X.X
尝试添加
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.6</version>
</dependency>
org.apache.struts
struts2型芯
2.1.6
亲爱的,这是Struts 2核心2.2.3.1 API的一部分
我试着运行你链接的项目,它对我来说正常工作。没有问题。使用此命令将Maven项目转换为Eclipse的动态Web项目:
mvn eclipse:eclipse -Dwtpversion=3.4.2
您可以更改您使用的任何WTP版本
.classpath
应该是这样的
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>X.X.X.X</version>
</dependency>
<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>
构建后,WAR文件应部署到%CATALINA\u BASE%\webapps
yop是否将jar文件添加到ClassPathYou show web.xml PLS库应位于web-INF中/lib@RomanC在我的构建路径中声明两次JAR可以吗?它现在已经在我的Maven依赖项下的构建路径中了。如果我把它放在我的lib文件夹中,它将在我的构建路径中有另一个条目。@vida您是从Eclipse部署的吗?如果是这样的话,试着从cmd构建war,然后将其部署到tomcat,而不需要Eclipse@vida请尝试添加我发现的依赖项,并告诉我问题是否已解决。为什么不使用最新的Struts2版本。@Aleksandr我没有问题,我们可以使用。但为了了解问题,我给出了该代码。我以前使用过该代码,我试过两个最新版本(2.3.12)还有其他一些较旧的版本,但到目前为止没有一个有效。正如我告诉你的,你共享的链接非常有效,你需要交叉检查你的项目。我可以知道你的Eclipse、Tomcat和Maven的版本吗?您是使用Eclipse的maven插件还是独立的maven插件?非常感谢。我正在使用EclipseJuno和EclipseMaven插件(maven 2),Tomcat6i正在使用m2e。我想它和你的一样。我只是用命令行来代替。无论如何,谢谢。我目前正在使用一个用于eclipse的maven插件。我相信它配置了项目,使其能够在Eclipse上运行。您是否尝试执行我的建议?@vida Eclipse Maven support是。。。糟糕;-)@罗曼克:是的。我编辑了我的.classpath文件。它在使用命令行时起作用:)