Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter in web.xml [duplicate]

This is my web.xml Code,While running I am getting error like this..How to resolve this?

"SEVERE: Exception starting filter Struts java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter"

 <?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">
      <display-name>HelloStruts</display-name>


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

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

      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
like image 835
kavie Avatar asked Jan 27 '15 10:01

kavie


People also ask

When to use strutsprepareandexecutefilter in Apache?

Struts 2 apache documentation says that when there is no other filter being used that can access action context information, better to use StrutsPrepareAndExecuteFilter filter. Now we will see how to use this filter in web.xml

What happened to FilterDispatcher in struts?

<filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> FilterDispatcher is deprecated since Struts 2.1.3. If you are working with older versions then user above solution.

How to change the filter class in struts2-core-X?

solution: check your struts2-core-x.x.jar version. -->if it is struts2-core-2.5.jar then change your filter class tag value in web.xml to <filter-class> org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter </filter-class> -->if it is struts2-core-2.1.3.jar then change your filter class tag value in web.xml to

Why Struts 2 controllers have different names in different jars?

Reason behind all this is struts 2 controllers are placed in different location in different version of struts2-core jar and some time they are called by different name as you can see in 2.1.3. Thank you, Share Improve this answer Follow answered May 31 '16 at 6:04


1 Answers

if you are using struts2 version 2.5 you need to change from:

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

to:

org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

Version Notes 2.5

like image 109
Alexandr Lihonosov Avatar answered Oct 12 '22 16:10

Alexandr Lihonosov