• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Struts + Tomcat 6 + HelloWorld = Pain

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I'm trying to setup a simple application using the above technologies. I'm actually following this tutorial: http://struts.apache.org/2.1.8.1/docs/hello-world.html
I searched and read many topics on this subject still I cant find a solution that works for me.

I created this directory: $CATALINA_BASE/webapps/HelloWorld with this structure:
../WEB-INF/web.xml
../WEB-INF/classes/struts.xml
../WEB-INF/classes/tutorial/HelloWorld.java and HelloWorld.class
../WEB-INF/lib/ -> filled with all the libs needed.
../HelloWorld.jsp

(HelloWorld.jsp, struts.xml and web.xml are just copy/paste from the same files I found in the tutorial above)

I fired up Tomcat and I deployed the application using the tomcat manager and I get this message: "OK - Started application at context path /HelloWorld" but browsing localhost:8080/HelloWorld leads to this error: HTTP Status 404 - There is no Action mapped for namespace / and action name .

As I said I looked inside the tomcat logs and on many many forums still I dont have a clue. :O

Any hints?


Thanks,

fadeh
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fadeh: Welcome to Java Ranch!

It sounds like you don't have a welcome page identified for your web application.

You've created a web application named "HelloWorld" (based on the name of the directory you created under "webapps".
When you browse to localhost:8080/HelloWorld, this is accessing the root of your web application, not the JSP page you have in the root of your web application. What happens when you try browsing to localhost:8080/HelloWorld/HelloWorld.jsp?

Otherwise, perhaps you could show the contents of your web.xml file (please use code tags for that).

Best Regards,
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"fedah fedaha", please check your private messages for an important administrative matter.
 
Giovanni Varesotti
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your answer Mark.

You're totally right, if I try to access /HelloWorld/HelloWorld.jsp I get rid of that error. Adding a <welcome-file-list> into web.xml should solve the problem (forgot this step after an entire day of fails using netbeans)
Anyway another problem has arisen: the browser returns a blank page (the title is setted properly, afterall).


Here's the code:

web.xml


struts.xml


HelloWorld.java


HelloWorld.jsp



Thank you,

Gio
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the context is HelloWorld, and the action name is HelloWorld, then the appropriate URL would be /HelloWorld/HelloWorld.
 
Giovanni Varesotti
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh.
My.

Lamest thread award.

Thank you Dave, it works. I would like to say that I got lot of problems with NetBeans+Struts2 in the first place and after a day of fails I tried to build the project manually and this thread actually show how I was tired

Anyway, thanks to your answers, looks like I've solved the problem even with NetBeans.. in fact the first problem was I placed struts.xml in the wrong dir (it should be under the default package) and the second arise when you run the project, NetBeans automatically opens a wrong url (localhost:8080/HelloWorld withouth the action part).


Thank you again and sorry for the lame question.

Gio
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We've all been there :)
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am also facing the same problem. I have tried different alternatives but failed to resolve
I am getting the welcome page and initPersonAction is working properly... but, when I try to invoke other actions it is giving me the problem:

2010-10-25 18:17:09,814 ERROR [org.apache.struts2.dispatcher.Dispatcher] - <Could not find action or result>
There is no Action mapped for namespace / and action name addPersonAction!add. - [unknown location]

I am trying to access one Action class with different action names and method names.

Please suggest me


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.objectFactory" value="spring" />
<constant name="struts.devMode" value="false" />
<constant name="struts.enable.DynamicMethodInvocation" value="false" />

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

<!-- Login Action -->
<action name="login" class="com.atos.referentiel.action.LoginAction">
<result name="SUCCESS">/WEB-INF/jsp/referentiel_home.jsp</result>
<result name="FAILURE">/WEB-INF/jsp/login_error.jsp</result>
</action>

<!-- Person Action -->

<action name="addPersonAction1" method="addPerson" class="com.atos.referentiel.action.PersonAction">
<result name="success">/WEB-INF/jsp/person/personMaster.jsp</result>
</action>

<action name="searchPersonAction" method="search" class="com.atos.referentiel.action.PersonAction">
<result name="success">/WEB-INF/jsp/person/personMaster.jsp</result>
</action>

<action name="initPersonAction" method="init" class="com.atos.referentiel.action.PersonAction">
<result name="success">/WEB-INF/jsp/person/personMaster.jsp</result>
</action>

<action name="addPersonAction" method="add" class="com.atos.referentiel.action.PersonAction">
<result name="input">/WEB-INF/jsp/person/addPerson.jsp</result>
</action>


<action name="loginError">
<result>login.jsp</result>
</action>
</package>

</struts>
 
reply
    Bookmark Topic Watch Topic
  • New Topic