2

I was making this hello world application using Struts2 and I've encountered an

HTTP Status 404 - /HelloStruts2/

Here is my web.xml

<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" version="3.0">
  <display-name>HelloStruts2</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

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

</web-app>

Here is my struts.xml

<?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.devMode" value="true" />

    <package name="basicstruts2" extends="struts-default">

        <action name="index">
            <result>WEB-INF/index.jsp</result>
        </action>

        <action name="hello" 
            class="actions.HelloWorldAction" method="execute">
            <result name="success">/HelloWorld.jsp</result>
        </action>

    </package>

</struts>

Here are the list of jars in my application

commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-logging-api-1.1.jar
freemarker-2.3.19.jar
javassist-3.15.0-GA.jar
jstl-1.2.jar
ognl-3.0.5.jar
struts2-core-2.3.7.jar
xwork-core-2.3.7.jar
user962206
  • 15,637
  • 61
  • 177
  • 270
  • u have posted the web.xml content two times. Please post the struts.xml file – Srinivas B Dec 05 '12 at 09:53
  • where did you kept your welcome files? – MohanaRao SV Dec 05 '12 at 09:58
  • Give error log. i had same problem in past and i resolved by changing jar files. Please check error log. i am sure problem in jar files. – MRX Dec 05 '12 at 10:13
  • What does it say in Tomcat's catalina.out? Most importantly, what does it say after you start the container ( or install the webapp ), and what does it say after you make the request? ALSO, you should probably document the whole request path that isn't working in your question: URL --> struts mapping --> Action class --> result template, etc. – chad Dec 05 '12 at 15:47

4 Answers4

2

I Have fixed it, It turns out that I just need the commons-lang jar to may lib directory.

user962206
  • 15,637
  • 61
  • 177
  • 270
1

Try the following code segment in web.xml(in the struts filter user the pattern *.action)

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>
Mayuran
  • 669
  • 2
  • 8
  • 39
  • There was nothing wrong with the posters /* mapping. In fact, it's suggested on the struts 2 documentation site . . . – chad Dec 05 '12 at 15:43
  • http://struts.apache.org/2.3.4.1/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html – chad Dec 05 '12 at 15:59
0

this is problem of jars. please check with following jars. i had same problem and i resolved with following jars.

commons-fileupload-1.2.1
commons-io-1.3.2
commons-logging-1.0.4
commons-logging-api-1.1
freemarker-2.3.16
javassist-3.14.0-GA
log4j-1.2.16
ognl-3.0
struts2-core-2.2.1.1
xwork-core-2.2.1.1
MRX
  • 1,611
  • 8
  • 33
  • 55
0

I had same problem, and i struggled to solve it for many hours, even i placed proper jars mentioned above.

I have faced this problem because there are too many jars files under the folder common->lib of the apache tomcat causing the issue.

So

1) Keep jars and there dependency neatly 2) Check jars under the lib folder of your web-inf for the dependency. 3) check jars containing same classes but having different version.

I found solution when i uninstalled tomcat and re-installed it.