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

kavie picture kavie · Jan 27, 2015 · Viewed 35k times · Source

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>

Answer

Alexandr Lihonosov picture Alexandr Lihonosov · Jun 30, 2016

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