javamaventomcatstruts2web.xml

Exception starting filter Struts 2


I am trying to set my first struts 2 application using annotations and maven. I'm follwing this example struts2 annotations example

when i try to run the application on tomcat server 7 i'm getting this exception

    Grave: Exception startin filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter. StrutsPrepareAndExecuteFilter
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

avr. 14, 2014 10:40:05 AM org.apache.catalina.core.StandardContext startInternal
Grave: Error filterStart
avr. 14, 2014 10:40:05 AM org.apache.catalina.core.StandardContext startInternal
Grave: Erreur de démarrage du contexte [/StrutsAnnotationsExample] suite aux erreurs précédentes
avr. 14, 2014 10:40:05 AM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["http-bio-8080"]
avr. 14, 2014 10:40:05 AM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["ajp-bio-8009"]
avr. 14, 2014 10:40:05 AM org.apache.catalina.startup.Catalina start
Infos: Server startup in 991 ms

Can any one help or tell what am i missing?


Solution

  • Looks like a typo in the code taken from the tutorial. Use the following in web.xml

    <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>