permaculture playing cards
The moose likes Struts and the fly likes Error:cannot find getDataSource(req) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Error:cannot find getDataSource(req)" Watch "Error:cannot find getDataSource(req)" New topic

Error:cannot find getDataSource(req)

amit sharma
Ranch Hand

Joined: Jul 19, 2006
Posts: 129
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
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
kapil patel
Ranch Hand

Joined: Sep 30, 2005
Posts: 33
If I am using tomcat server, how I can define datasource in tomcat.

kapil patel
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The process is different for versions 4 and 5. Assuming you're using version 5, here is the link.
I agree. Here's the link:
subject: Error:cannot find getDataSource(req)
It's not a secret anymore!