5

I copied all struts2 jars to the WEB-INF/lib folder and the struts.xml file is as shown below:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">*

I'm still getting this exception while running the application.
How can I solve this?

1
  • Check that all jar-s are in your war file as well. Commented Dec 20, 2012 at 11:00

4 Answers 4

9

For new release of Struts2 class path changed as like below (Struts 2.5)

org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

Package names have changed Some classes were moved to different packages, see the list below for more details:


New:


org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
org.apache.struts2.dispatcher.filter.StrutsExecuteFilter
org.apache.struts2.dispatcher.filter.StrutsPrepareFilter
org.apache.struts2.dispatcher.listener.StrutsListener
org.apache.struts2.result.ServletRedirectResult
com.opensymphony.xwork2.interceptor.ValidationAware 

Old:


org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
org.apache.struts2.dispatcher.ng.listener.StrutsListener
org.apache.struts2.dispatcher.ServletRedirectResult
com.opensymphony.xwork2.ValidationAware 

For More Detail Click Here

Sign up to request clarification or add additional context in comments.

1 Comment

For me this class was mentioned in my web.xml; performing a global search within my project for "StrutsPrepareAndExecuteFilter" helped me identify where this library was getting included in my project.
3

Regarding to the error mentioned SEVERE: Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

PROBLEM: There seems to be a problem with the following combination Eclipse - WTPPlugin - Struts2 - Maven3

FINDINGS: We assume that when we run a project as "Run on server" we assume that eclipse runs maven, created WAR file and deploys on the server. But its not working perfectly for me. I do see the WAR file in the target folder where maven creates WAR, and the WAR is perfect. But eclipse seems to run something else.

SOLUTION: Put all the required JAR files into eclipse project's WEB-INF/lib. If you are using version control, make sure to ignore the lib folder. How to find all the required JARs when you are using maven? Go to target folder and the WAR file. Burst it open and go to WEB-INF/lib. Copy all these JARS to eclipse project's WEB-INF/lib.

Thanks, Harsh

1 Comment

Your method is perfect that what i suspect too but when i exported the project as a war file and imported it into a separated tomcat server it dosen't run
1

Include this mapping in your web.xml file

<filter> 
       <filter-name>struts2</filter-name> 
       <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 
      </filter>

    <filter-mapping> 
       <filter-name>struts2</filter-name> 
       <url-pattern>/*</url-pattern> 
      </filter-mapping>

1 Comment

How dould this be related to the class not found? I don't even know how it would be looking for that filter if it had not already been mapped? Am I missing something?
1

It happened with me, and I solve it by recreating the artifacts from Intellij settings. If you use Intellij, you need to recreate the Artifacts for your web project again.

  • Go to File --> Project structure
  • Select Artifacts from the left tab.
  • Remove the current artifacts by select the artifacts and click on (-) button at the top of your Artifacts.
  • Add new artifacts, first war exploded then war archive.
  • Enjoy.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.