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>
Roman C
  • 49,761
  • 33
  • 66
  • 176
Sourav
  • 91
  • 1
  • 6
  • 12

2 Answers2

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
soorapadman
  • 4,451
  • 7
  • 35
  • 47
  • Can you tell me the procedure to add them . Actually, I have added them, but I guess they are not working properly :( – Sourav Sep 16 '15 at 04:35
  • 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. – soorapadman Sep 16 '15 at 04:36
  • 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. – Sourav Sep 16 '15 at 04:43
  • 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) – Sourav Sep 16 '15 at 05:59
  • This is the new probz I am facing.... – Sourav Sep 16 '15 at 06:00
  • your error seems incomplete i can't figure out – soorapadman Sep 16 '15 at 07:08
  • yup.... the rest of the errors are----- – Sourav Sep 16 '15 at 07:12
  • at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5081) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) – Sourav Sep 16 '15 at 07:16
  • at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) – Sourav Sep 16 '15 at 07:17
  • at org.apache.catalina.startup.Catalina.start(Catalina.java:620) – Sourav Sep 16 '15 at 07:17
  • at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431) – Sourav Sep 16 '15 at 07:20
  • Hi, Its done... I could figure out the prob. – Sourav Sep 16 '15 at 12:13
  • Sep 16, 2015 5:41:57 PM org.apache.struts2.dispatcher.Dispatcher warn WARNING: Could not find action or result: /Login_Reg/loginauth.action There is no Action mapped for namespace [/] and action name [loginauth] associated with context path [/Login_Reg]. - [unknown location] – Sourav Sep 16 '15 at 12:13
  • Its a new one.. Can you help? – Sourav Sep 16 '15 at 12:14
  • The above error message is saying that the action class is not available, it means you are did something wrong in your action class configuration, may be it’s a namespace or typo error, just double check the name. – soorapadman Sep 16 '15 at 12:17
  • check this link it may helpful http://stackoverflow.com/questions/21097002/struts-2-there-is-no-action-mapped-for-namespace – soorapadman Sep 16 '15 at 12:18
  • pages/login.jsp pages/welcome.jsp /welcome pages/login.jsp – Sourav Sep 16 '15 at 12:21
  • I m trying to figure it out. Thanks for your time – Sourav Sep 16 '15 at 12:22
  • Do me a favor create a new question and post the code checking all this in comment not worthy – soorapadman Sep 16 '15 at 12:22
  • Thanks for your help-- I have posted a new questionp--- – Sourav Sep 16 '15 at 12:39
  • http://stackoverflow.com/questions/32608853/there-is-no-action-mapped-for-namespace-and-action-name-loginauth-associat – Sourav Sep 16 '15 at 12:39
  • above mentioned link is for the new question.. – Sourav Sep 16 '15 at 12:39
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
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449