Help with Datasource binding
statefan03 Sep 28, 2011 8:42 AMHi all,
I have an existing application that works fine on JBoss 5.1 but I can't get the datasource binding to work on JBoss 7. I've been going through the documentation of what has changed here:
https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7
specifically in the "Update application JNDI namespace names" section. But I'm still having problems.
I'm using the Web Profile build - jboss-as-web-7.0.0.Final.
I've deployed the JDBC driver and my Datasource binds correctly according to this message in the system output:
07:48:51,053 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) Deploying JDBC-compliant driver class com.ibm.db2.jcc.DB2Driver (version 4.11)
07:48:51,060 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) Bound data source [java:jdbc/MyDataSource]
However, when I try to deploy my WAR file I'll get the following error:
07:49:26,191 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "MyApp.war"
07:49:26,848 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployment of "MyApp.war" was rolled back with failure message {"Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"MyApp.war\".jndiDependencyService missing [ jboss.naming.context.java.module.MyApp.MyApp.env/jdbc/MyDataSource ]","jboss.naming.context.java.module.MyApp.MyApp.env/jdbc/MyDataSource.jboss.deployment.unit.\"MyApp.war\".module.MyApp.MyApp.0 missing [ jboss.naming.context.java.java:jdbc/MyDataSource ]"]}
07:49:26,848 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) Service status report
New missing/unsatisfied dependencies:
service jboss.naming.context.java.java:jdbc/MyDataSource (missing)
service jboss.naming.context.java.module.MyApp.MyApp.env/jdbc/MyDataSource (missing)
I'm not sure what needs to change in my App bindings to match this datasource on the server. My web.xml and jboss-web.xml definitions look like this:
web.xml
<resource-ref id="ResourceRef_1">
<res-ref-name>jdbc/MyDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
jboss-web.xml
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/MyDataSource</res-ref-name>
<jndi-name>jdbc/MyDataSource</jndi-name>
</resource-ref>
</jboss-web>
Any help would be greatly appreciated!