Exception Starting Filter Struts2 - Tried Adding Jar'S, But Same Result

Exception starting filter struts2 - tried adding JAR's, but same result

Since you are using Struts 2.3,

FilterDispatcher is deprecated. You MUST use StrutsPrepareAndExecuteFilter (or its little brothers).

From the official documentation

Deprecated. Since Struts 2.1.3, use StrutsPrepareAndExecuteFilter instead or StrutsPrepareFilter and StrutsExecuteFilter if needing using the ActionContextCleanUp filter in addition to this one

change then this

<!-- Struts < 2.1.3 -->
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>

to this:

<!-- Struts >= 2.1.3 and < 2.5 -->
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>

Note that, from 2.5, it would be instead:

<!-- Struts >= 2.5 -->
<filter-class>
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>

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 -- Exception starting filter struts

I replaced all the jar files I had with the ones from another application I have that's working and doesn't have this issue. This application works now. I'm guessing there was some clash between jar files that was causing the problem.

Exception starting filter struts2:NoSuchMethodError

struts.jar
struts2-convention-plugin-2.1.6.jar
struts2-core-2.3.14.3.jar
struts2-json-plugin-2.1.8.1.jar
struts2-tiles-plugin-2.1.6.jar
xwork2.jar
xwork-core-2.3.14.jar

This is beyond evilness. ALL the resources must be aligned (same version), and possibly updated to the latest version due to security issues. Also remove struts.jar and xwork2.jar (!!).

Then you need

struts.jar
struts2-convention-plugin-2.3.16.3.jar
struts2-core-2.3.16.3.jar
struts2-json-plugin-2.3.16.3.jar
struts2-tiles-plugin-2.3.16.3.jar

xwork2.jar
xwork-core-2.3.16.3.jar

Also update ognl.jar and freemarker.jar because they're old:

  • latest ognl.jar;
  • latest freemarker.jar.


Related Topics



Leave a reply



Submit