• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Hello World with Struts2

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Java friends,

I am beginner to struts2 and yesterday i did a simple Hello World Program but I got an error .

Here is my program and my exceptions .

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>

<package name="default" extends="struts-default" namespace="/">
<action name="getTut" class="org.com.struts.TutAction">
<result name="success">/success.jsp</result>
<result name="failure">/error.jsp</result>
</action>
</package>

</struts>

here is my web.xml ::

<?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>Struts2App</display-name>

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

and here is my java class ::

package org.com.struts;

public class TutAction {
public String execute(){
System.out.println("Hello.! from struts");
return "success";
}
}

and now what i did run an application and i appended at the end
http://localhost:8080/Struts2App/getTut.action //<--

but i got this error ::

HTTP Status 404 - There is no Action mapped for action name getTut.action/.
type Status report
message There is no Action mapped for action name getTut.action/.
description The requested resource (There is no Action mapped for action name getTut.action/.) is not available.
Apache Tomcat/6.0.35

is my method wrong or what happened and i have added following jar's ::

1]struts2-core-2.3.4.jar
2]commons-fileupload-1.2.2.jar
3]commons-io-2.0.1.jar
4]commons-lang-2.4.jar
5]commons-lang3-3.1.jar
6]commons-logging-1.1.1.jar
7]commons-logging-api-1.1.jar
8]freemarker-2.3.19.jar
9]javassist-3.11.0.GA.jar
10]ognl-3.0.5.jar

friends please help me out. I did program 4 times but still i got same error for that i install and uninstall tomcat6 5-6 times.! friends please help me.!

you can run my program and tell me is there any mistake i did or need to add something. i know problem arising only within either "struts.xml" or "web.xml" but where .?

Thanking you.!



 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Post your project Structure.

install and uninstall tomcat6 5-6 times.

You are doing something wrong why you are screwing tomcat. :P
 
Amey Ambulgekar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

i got the solution for this struts program i just changed jar files means i changed from ::


1]struts2-core-2.3.4.jar to struts2-core-2.0.11.jar <--
2]commons-fileupload-1.2.2.jar kept as it is
3]commons-io-2.0.1.jar kept as it is
4]commons-lang-2.4.jar kept as it is
5]commons-lang3-3.1.jar kept as it is
6]commons-logging-1.1.1.jar kept as it is
7]commons-logging-api-1.1.jar kept as it is
8]freemarker-2.3.19.jar kept as it is
9]javassist-3.11.0.GA.jar kept as it is
10]ognl-3.0.5.jar to ognl-2.6.11.jar <--
11]xwork-core-2.3.4.jar to xwork-2.0.4.jar <--

so it works i am very happy


but still i have one question --> when i download struts2.1.8 jars and use for application then it gives me error such as resource not found .!
why is it so..?

Thanking you all.!


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic