• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot retrieve mapping for action /

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Vinod Awar
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill

My form looks like


and i have put correct action mappings in strutsconfig also.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic