wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts 2 problem -- There is no Action mapped for namespace / and action name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 problem -- There is no Action mapped for namespace / and action name" Watch "Struts 2 problem -- There is no Action mapped for namespace / and action name" New topic
Author

Struts 2 problem -- There is no Action mapped for namespace / and action name

Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
Hello. I have a Struts2 application in Eclipse. I'm getting the following error, and for the life of me I can't figure out why.



Here is the form in my JSP:



Here is the relevant portion of my struts.xml, which is located at C:\ghs86reunion\GHS86Reunion\src\struts2_resources.



My action class, ProcessCommet is located at C:\ghs86reunion\GHS86Reunion\src\action. I have all the relevant jar classes in my class path, and they are also located at C:\ghs86reunion\GHS86Reunion\WebContent\WEB-INF\lib. Can anyone help me with this? Thanks in advance.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Hi Frank, welcome to javaranch.

Frank can you show us the package configuration of your struts.xml file?? If your package has a namespace, then you'll have to use that namespace in the s:form tag too...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

A couple of other notes:

1) I assume you're using the "simple" theme (or a custom theme) by default?
2) I also assume you're returning the same strings you use to name your results and *not* Action.SUCCESS etc.--because they have different values than your result names.
3) Telling us the full path of your web app source isn't actually that useful; it's more important to know what's actually being deployed.

How are you deploying your app?

You can use the Struts 2 Config Browser plugin to find out what Struts 2 thinks your configuration looks like.
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
Ankit Garg wrote:Hi Frank, welcome to javaranch.

Frank can you show us the package configuration of your struts.xml file?? If your package has a namespace, then you'll have to use that namespace in the s:form tag too...


Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
David Newton wrote:A couple of other notes:

1) I assume you're using the "simple" theme (or a custom theme) by default?
2) I also assume you're returning the same strings you use to name your results and *not* Action.SUCCESS etc.--because they have different values than your result names.
3) Telling us the full path of your web app source isn't actually that useful; it's more important to know what's actually being deployed.

How are you deploying your app?

You can use the Struts 2 Config Browser plugin to find out what Struts 2 thinks your configuration looks like.


1. I believe it's the simple theme. I can't remember what I put down for that when I was creating the project, but I can't imagine I would have purposely complicated things any more that I had to.

2. Yes, the same strings.

3. This isn't actually on a server per se, as yet. I'm still running this from Eclipse.

The Struts 2 Config Browser plugin would appear to be an excellent tool for trying to solve my problem, but I'm looking at the link below, and it's telling me to copy "the jar" into my application, without specifying exactly which jar or where to put it (I'm presuming my /lib directory, as I can't think of anywhere else I would put it.) Any advice on this?

http://struts.apache.org/2.x/docs/config-browser-plugin.html
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

> I believe it's the simple theme. I can't remember what I put down for that when I was creating the project

"Put down for that"? I don't know how to parse that in this context. My point was that if you're not using the "simple" theme your HTML is going to be invalid: take a look at the rendered HTML. The default "xhtml" theme renders tables/rows/cells for form elements and labels.

> This isn't actually on a server per se, as yet. I'm still running this from Eclipse.

Deployed is deployed--there's a server *somewhere*, or you wouldn't be seeing *anything* :)

> it's telling me to copy "the jar" into my application, without specifying exactly which jar or where to put it (I'm presuming my /lib directory, as I can't think of anywhere else I would put it.) Any advice on this?

The config-browser jar, and in the context of a web application, "into the application" means to anywhere that will be deployed.
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
> I believe it's the simple theme. I can't remember what I put down for that when I was creating the project

"Put down for that"? I don't know how to parse that in this context. My point was that if you're not using the "simple" theme your HTML is going to be invalid: take a look at the rendered HTML. The default "xhtml" theme renders tables/rows/cells for form elements and labels.


Well, since my JSP itself is being rendered correctly, it looks like I'm using the simple theme.

> This isn't actually on a server per se, as yet. I'm still running this from Eclipse.

Deployed is deployed--there's a server *somewhere*, or you wouldn't be seeing *anything* :)


Okay, I'm using Tomcat. The code just isn't anywhere in my Tomcat directory, but since the JSP is coming up I'm presuming that's of little concern (unless I want everybody to be able to access my app, in which case it needs to be on a server somewhere, but that's for when I get everything working).

> it's telling me to copy "the jar" into my application, without specifying exactly which jar or where to put it (I'm presuming my /lib directory, as I can't think of anywhere else I would put it.) Any advice on this?

The config-browser jar, and in the context of a web application, "into the application" means to anywhere that will be deployed.


The above link provided no way for me to download a jar by that name. By Googling, I was able to find a jar called struts2-config-browser-plugin-2.1.6.jar. I put that in my /lib directory, but I am now confused as to what URL to put in my browser. Any advice?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It comes in the Struts 2 distro--there's no reason to guess what you need. The plugin documentation page pretty much sums up how to use it.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Checkout this...

[Edit: beaten by 17 seconds ]
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
David Newton wrote:It comes in the Struts 2 distro--there's no reason to guess what you need. The plugin documentation page pretty much sums up how to use it.


Okay, I've got the right jar in my /lib and the action information in my browser. (My problem was that I was just using the basic Struts jars rather than all the Struts jars.) I substituted my project name for the word "starter" in the link, and the configuration browser came up.

So back to my original question. According to the link, no actions are in the default namespace. So obviously, I've configured something wrong. I just don't know what. Any advice?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Frank Serkland wrote:(My problem was that I was just using the basic Struts jars rather than all the Struts jars.)

Using *all* the S2 jars will cause another completely different set of problems. You can't randomly include S2 libraries, particularly plugins, as each can introduce an arbitrary set of dependencies.

I'd turn devMode on, turn up the log level to DEBUG, and see what's in the logs at startup.
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
David Newton wrote:I'd turn devMode on, turn up the log level to DEBUG, and see what's in the logs at startup.


Okay, time for my dumbest question of all, and feel free to slap me upside the head, because I feel like I should know the answer to this, but believe it or not, I don't, and I've been unable to find a simple answer from multiple Google searches...

How do I do what you've suggested? If it's important, I'm using Eclipse Galileo under Windows 7.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 510

Frank Serkland wrote:Hello. I have a Struts2 application in Eclipse. I'm getting the following error, and for the life of me I can't figure out why.



Here is the form in my JSP:



Well, Frank, just a small suggestion, try giving ProcessComment.action like,



Regards, Prasad
SCJP 5 (93%)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

You can find an example of how to turn devMode on here.

As for logging, I think you can do that by including a log4j.properties file in your classpath (along with struts.xml) which contains an appender configuration like this
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
Ankit Garg wrote:You can find an example of how to turn devMode on here.


After turning on devMode, here is what comes up.


Since this thread is getting longer than I expected, here, for everyone's convenience (so you don't have to scroll up), is my original struts.xml.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

We need to see the startup logs, with debug logging enabled.
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
David Newton wrote:We need to see the startup logs, with debug logging enabled.


Well, here is what's in the Eclipse console. I'm not sure where to find the startup logs.

Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
Ankit Garg wrote:As for logging, I think you can do that by including a log4j.properties file in your classpath (along with struts.xml) which contains an appender configuration like this


Another dumb question. Is there a specific place I should put the log4j.properties file? And would I put it my classpath the same way I'd put a jar file?
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
David Newton wrote:We need to see the startup logs, with debug logging enabled.


I don't know if these will help, but these and similar errors are coming up in my Eclipse error log.




This error I can't understand, as I'm not even using any web services in this app.

Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
Frank Serkland wrote:
David Newton wrote:We need to see the startup logs, with debug logging enabled.


After nosing around on my hard drive, I found this. Is this what you need to see?

Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
David Newton wrote:We need to see the startup logs, with debug logging enabled.
Jun 24, 2010 10:14:58 AM org.apache.tomcat.util.digester.SetPropertiesRule begin

Is this the startup log? It showed up in my console.
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
Frank Serkland wrote:Is this the startup log? It showed up in my console.


Would someone out there be okay with the thought of me e-mailing them my project and looking at it? If so, click on my name and e-mail me privately.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Frank Serkland wrote:Is there a specific place I should put the log4j.properties file? And would I put it my classpath the same way I'd put a jar file?

Not the same way, no, because jar files are handled differently. The default deployment location would be in /WEB-INF/classes (i.e. the root of your own code).
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Redeployment issue; could be caused by already having a running Tomcat, could be a typical library unload issue.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Something is going wrong with your environment, or your JSP is wrong.

Please UseTheForumNotEmail.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Is your struts2_resources directory listed as being a source directory? In other words, is your S2 config file even being deployed?

You state that your actions are under /src/action, and your config is under /src/struts2_resources--that would put the struts config file in a non-default location under normal circumstances.
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 104
David Newton wrote:Is your struts2_resources directory listed as being a source directory? In other words, is your S2 config file even being deployed?

You state that your actions are under /src/action, and your config is under /src/struts2_resources--that would put the struts config file in a non-default location under normal circumstances.


Actually, I just solved this whole problem. My struts.xml was under /src/struts2_properties, and when I moved it to /src, I finally got the machine to find my class. Sometimes it's the simplest things that are the answer, and yet those can be the hardest to find. Go figure...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I guess it wasn't :)
 
Don't get me started about those stupid light bulbs.
 
subject: Struts 2 problem -- There is no Action mapped for namespace / and action name