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>
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
<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.
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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With