File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts 2+jboss4.0.4+eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2+jboss4.0.4+eclipse" Watch "struts 2+jboss4.0.4+eclipse" New topic

struts 2+jboss4.0.4+eclipse

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 241
hi guys

iam trying to do a sample in which iam trying to connect to database using datasource configured in stuts-config.xml like below
<pre name="code" class="core"> <data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource" key="DB">
<set-property property="autoCommit" value="false"/>
<set-property property="description" value="Configuration"/>
<set-property property="driverClass" value="com.mysql.jdbc.Driver"/>
<set-property property="maxCount" value="4"/>
<set-property property="minCount" value="2"/>
<set-property property="user" value="root"/>
<set-property property="password" value="admin"/>
<set-property property="url" value="jdbc:mysql://localhost:3306/sync" />
<set-property property="validationQuery" value="SELECT COUNT(*) FROM user" />

but iend up in getting error like below even though my password and user name are correct and having proper privilages

19:05:59,009 ERROR [ActionServlet] Initializing application data source DB
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user ''@'localhost' (using password: YES))
at org.apache.commons.dbcp.BasicDataSource.createDataSource(
at org.apache.commons.dbcp.BasicDataSource.setLogWriter(
at org.apache.struts.action.ActionServlet.initModuleDataSources(
at org.apache.struts.action.ActionServlet.init(
at javax.servlet.GenericServlet.init(
at org.apache.catalina.core.StandardWrapper.loadServlet(
at org.apache.catalina.core.StandardWrapper.allocate(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
at Source)
Caused by: java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.secureAuth411(
at com.mysql.jdbc.MysqlIO.doHandshake(
at com.mysql.jdbc.Connection.createNewIO(
at com.mysql.jdbc.Connection.<init>(
at com.mysql.jdbc.NonRegisteringDriver.connect(
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(
at org.apache.commons.dbcp.BasicDataSource.createDataSource(
... 19 more
19:05:59,009 INFO [[/ax]] Marking servlet action as unavailable
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It is not a good idea to use the Struts DataSource utility. It's deprecated in later versions and is very error-prone. My suggestion would be to use the JBOSS uilities for setting up a JNDI DataSource and then use a JNDI lookup in your code to retrieve it.

Also, the subject heading for this thread is incorrect. You're obviously using Struts 1, not Struts 2 since Struts 2 has no struts-config.xml file.
[ July 15, 2008: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 241
thanks Merrill
for your suggestion .but i want to examine this database connectivity
iam not going to use it in my project its just a trial

looking for your replies
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I have a hard time understanding why you would want to learn how to use something that's almost universally agreed to be bad form. Aside from the fact that it doesn't work very well, using the Struts Data Source violates the separation of model code from controller code in the MVC Model, which is why it was deprecated in later releases.

I can't help you with it, as I stopped wanting to know anything about it once I determined it was bad form to use it.
[ July 16, 2008: Message edited by: Merrill Higginson ]
I agree. Here's the link:
subject: struts 2+jboss4.0.4+eclipse
It's not a secret anymore!