Java.Lang.Classnotfoundexception: Org.Apache.Struts2.Dispatcher.Ng.Filter.Strutsprepareandexecutefilter When Starting Simple Struts2 Application

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

  1. Go to the Markers tab (If you can't see, do Windows > Show View > Markers)
  2. Expand "Classpath Dependency Validator Message"
  3. Right click "Classpath entry org.eclipse.jdt.USER_LIBRARY/struts2 will not be exported or published. Runtime ClassNotFoundExceptions may result."
  4. Click "Quick Fix"
  5. Select "Mark the associated raw classpath entry as a publish/export dependency."
  6. 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



Leave a reply



Submit