wood burning stoves 2.0*
The moose likes Struts and the fly likes Cannot retrieve mapping for action / Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cannot retrieve mapping for action /" Watch "Cannot retrieve mapping for action /" New topic
Author

Cannot retrieve mapping for action /

Vinod Awar
Ranch Hand

Joined: Nov 06, 2006
Posts: 125
Hello java guru's

iam trying to connect to postgresql from my application. my struts-config.xml looks like


but iam getting this exception


i have added all struts jar files and commonspool and dbcp jars also.
i can connect to postgres from other applications.

Thanks for reply


The biggest bankruptcy is the loss of enthusiasm
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
First of all, this message has nothing to do with database access. Struts is telling you that you specified an action of "/" in the <html:form> tag of your JSP, and that isn't a valid action.

Secondly, the Struts DataSource declaration utility has been deprecated, and is not recommended to be used any more. The best practice for using a JDBC DataSource in a Struts or any J2EE application is to use your Application Server's recommended method for declaring a JNDI DataSource, and then use JNDI to look up the datasource in your code.
[ March 13, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Vinod Awar
Ranch Hand

Joined: Nov 06, 2006
Posts: 125
Thanks Merill

My form looks like


and i have put correct action mappings in strutsconfig also.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It's possible that by putting the database declaration in your struts-config.xml file, the file has somehow become un-parseable. Check for error messages in your logs for the time period when your server is first starting up. In order to test this theory, try removing all the database declaration information from your struts-config.xml file and see if that fixes the "cannot retrieve mapping" problem.

Even before it was deprecated, the Struts DataSource declaration facility was nothing but trouble. If you search this forum, you will find many reports of problems with this utility, many of which have never been solved. Believe me, you're much better off declaring your DataSource as a JNDI resource than declaring it in Struts.
Vinod Awar
Ranch Hand

Joined: Nov 06, 2006
Posts: 125
iam using NetBeans 5.5. i dont see any exceptions when i deploy and run the application.i can access the search page by entering the url.
But i cannot retrieve the data from database.Iam getting exceptions whenever i start the tomcat.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The following lines in your stack trace:

are telling you that when the Struts ActionServlet tried to execute it's init() method at initialization time, it failed when it was "Initializing application data source usage" thereby rendering the Struts ActionServlet "Unavailable".

Translation: Putting the DataSource definition in your struts-config.xml file is messing up your entire application. I've already given you the best way to fix it: Remove the DataSource definition from your struts-config.xml file and instead definie it as a JNDI resource in Tomcat. See this link for more information on how to do that.

Even if you do by some miracle come up with something that will fix your Struts DataSource configuration, you will in the end still have a solution that is inferior to using Tomcat's Connection pooling. Furthermore, you will have made it so you can't upgrade your application to a newer version of Struts because it's no longer supported in version 1.3.5 and above.
[ March 13, 2007: Message edited by: Merrill Higginson ]
Vinod Awar
Ranch Hand

Joined: Nov 06, 2006
Posts: 125
Merill

i have tried by removing the datasource configuration from struts-config.xml and edited server.xml and web.xml for jndi. But when i start the tomcat i am getting the following exception.


i can connect the database from other programs. do i need to add any other jar files?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One possibility is that the Application server may be using an old copy of the application. Are you sure you redeployed it? Are you sure you removed all entries related to DataSources?

I don't see how it would be possible to get this message if you had successfully removed all references to a Datasource in your struts-config.xml file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot retrieve mapping for action /