It's not a secret anymore!*
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
Author

struts 2+jboss4.0.4+eclipse

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
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
<blockquote>code:
<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" />
</data-source>
</data-sources>
</pre>
</blockquote>

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(BasicDataSource.java:855)
at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:598)
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:808)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2644)
at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:877)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
... 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 ]

Merrill
Consultant, Sima Solutions
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
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
amir
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: struts 2+jboss4.0.4+eclipse
 
Similar Threads
MySQL error
Error in Hibernate url for mysql ?
DataSource : No suitable driver
mysql query
Connection pooling