Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
I figured out my problem was that I forgot to export my user defined libraries, in this case, struts libraries. You can export the libraries via Eclipse by
- Go to the Markers tab (If you can't see, do Windows > Show View > Markers)
- Expand "Classpath Dependency Validator Message"
- Right click "Classpath entry org.eclipse.jdt.USER_LIBRARY/struts2 will not be exported or published. Runtime ClassNotFoundExceptions may result."
- Click "Quick Fix"
- Select "Mark the associated raw classpath entry as a publish/export dependency."
- click "Finish"
Struts2 -java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
Struts2 requires a certain number of jar files before executing your programs. Make sure you have these included in your editing tools:
commons-logging-x.x.jar
freemarker-x.x.jar
xwork-x.x.jar
struts2-core-x.x.jar
ognl-x.x.jar
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter at building normal struts login application
Sometimes additional imported dependencies can cause this type of error. Try reducing to the minimum required dependencies for a Struts 2 application.
See the linked question/answer for more help regarding this error.
Additional information:
How To Create A Struts 2 Web Application
java.lang.ClassNotFoundException: org.apache.Struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
I think your class define in web.xml is wrong. its org.apache.struts2.dispatcher.filter.ng.StrutsPrepareAndExecuteFilter not
org.apache.Struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter when starting Simple Struts2 Application
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
.
Related Topics
How to Set an Environment Variable at Runtime from Java
Deserialize Java 8 Localdatetime with Jacksonmapper
Pros and Cons of Package Private Classes in Java
Java: How to Use Urlconnection to Post Request with Authorization
Create Custom Annotation for Lombok
Why Doesn't Java.Util.Collection Implement the New Stream Interface
How to Show Changes Between Commits with Jgit
Why in Java Enum Is Declared as Enum<E Extends Enum<E>>
Java: Set Timeout on a Certain Block of Code
How to Stop the Task Scheduled in Java.Util.Timer Class
Is There Something Like Instanceof(Class<> C) in Java
Jackson Change JSONignore Dynamically
How to Change the Color of Specific Words in a Jtextpane
How to Get the Parent Base Class Object Super.Getclass()
Why Does Hibernate Disable Insert Batching When Using an Identity Identifier Generator