Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error:cannot find getDataSource(req)

 
amit sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my action class i get this error
cannot find symbol
symbol : method getDataSource(javax.servlet.http.HttpServletRequest)
My code
How to fix this error
Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you've upgraded to the latest version of Struts(1.3.5), the getDataSource method has been removed from the Action class. Support for the Struts DataSource utility has also been removed from Version 1.3 of the DTD used by the Struts-config.xml file.

Anyone who follows this forum regularly is probably tired of my continually telling people not to use the Struts DataSource utility. One of the reasons I've been telling people not to use it is that the Struts authors did not guarantee that it would be supported in future versions. Well, guess what? The most recent version doesn't support it.

The best practice for setting up a DataSource in a Struts application or any J2EE application is to define it as a JNDI resource using your application server's interface for defining such resources. In your application code, you then do a JNDI lookup to retrieve the DataSource.
 
kapil patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am using tomcat server, how I can define datasource in tomcat.

thanks,
kapil patel
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The process is different for versions 4 and 5. Assuming you're using version 5, here is the link.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic