0

I am trying out Struts 2 for first time. I am trying to create a simple Login App. But, I am getting the following Exceptions/Errors:

SEVERE: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:252)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4562)
    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5240)
    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5235)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Sep 16, 2015 12:21:35 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Sep 16, 2015 12:21:35 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Loginreg] startup failed due to previous errors

I am trying to fix it since evening, but unable to fix it. I have searched few materials , but issue was not solved. I have installed 6 basic jar files needed for Struts 2 app. Following are my WEB.xml and Struts.xml File..

<?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_3_0.xsd" id="WebApp_ID" version="3.0">
    <display-name>Login-reg</display-name>

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>

    </welcome-file-list>
</web-app>

This is my Struts.xml file

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">

    <struts>
        <constant name="struts.enable.DynamicMethodInvocation"
            value="false" />
        <constant name="struts.devMode" value="false" />

        <constant name="struts.custom.i18n.resources"
            value="ApplicationResources" />

        <package name="default" extends="struts-default" namespace="/">

            <action name="login" method="authenticate"
                class="com.struts2.login.LoginAction">
                <result name="success">Welcome.jsp</result>
                <result name="error">Login.jsp</result>

            </action>
        </package>
    </struts>
2
  • Looks like you don't have struts jar in classpath Commented Sep 16, 2015 at 4:14
  • Unrelated, but note that you appear to be using a fairly old version of Struts 2. Commented Sep 16, 2015 at 16:39

2 Answers 2

1

Struts2 requires a certain number of jar files before executing your programs. Make sure you have these included in your editing tools:

commons-logging-x.x.jar
freemarker-x.x.jar
xwork-x.x.jar
struts2-core-x.x.jar
ognl-x.x.jar
Sign up to request clarification or add additional context in comments.

22 Comments

Can you tell me the procedure to add them . Actually, I have added them, but I guess they are not working properly :(
If you are using Eclipse then adding the required libraries just in Java Build Path will not work. You have to again add those libraries in Deployment Assembly. Right Click On Project>> Properties >> select Deployment Assemlby . Add required Java Build Path entries by clicking on Add.. button.
Thanks for your help. After following the procedure you said, I could get rid of this filterDispatcher Exception. However, New errors are coming (but not related to FilterDispatcher ). I am trying to figure it out . In case I can not figure this out, I will get back to you . Thanks a lot.
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1543) at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1694) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1209) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:882) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:317) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
This is the new probz I am facing....
|
0

Your web.xml should be like

<?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_3_0.xsd" id="WebApp_ID" version="3.0">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  </web-app>

and copy the below jars in WEB-INF/lib folder.

struts2-core-2.3.32.jar
xwork-core-2.3.32.jar
ognl-3.0.19.jar
freemarker-2.3.22.jar
javassist-3.11.0.GA.jar
commons-logging-1.1.3.jar

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.