11 Replies Latest reply on Dec 12, 2012 5:43 AM by ananymous7239

    Help with Datasource binding

    statefan03

      Hi 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!

        • 1. Re: Help with Datasource binding
          statefan03

          And I just want to add in the application code I'm doing the datasource lookup like this, even though the failure is during deployment well before I can execute this:

           

          datasource = (DataSource) context.lookup("java:comp/env/jdbc/MyDataSource");

          • 2. Re: Help with Datasource binding
            jaikiran

            1) Use 7.0.2 AS version

            2) Datasources in AS7 can only be bound under the  java:jboss/ namespace (i.e. java:jdbc/ isn't allowed). See this http://lists.jboss.org/pipermail/jboss-as7-dev/2011-July/002890.html

            1 of 1 people found this helpful
            • 3. Re: Help with Datasource binding
              statefan03

              Thanks for the help.  I'm still having trouble though.  Here's what I've done:

               

              1) upgraded to 7.0.2.

               

              2) Created the datasource according to the new rules:

               

              07:39:56,911 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) Bound data source [java:jboss/datasources/MyDataSource]

               

              3) Removed the jboss-web.xml since I was getting a CircularDependencyException with it.

               

              4) updated the web.xml to use this datasource definition

               

              <resource-ref id="ResourceRef_1">

                       <res-ref-name>java:jboss/datasources/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>

               

               

              When I try and deploy this I get this exception:

               

              07:59:03,360 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 2) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.myapp.myapp.env.jboss.datasources.MyDataSource missing [ jboss.naming.context.java.jboss.resources.jboss.datasources.MyDataSource ]"]}}}

               

               

               

              I also tried just "jboss/datasources/MyDataSource" without the java: but that didn't work either. 

               

              Can anyone show a sample of how this is done?

              • 4. Re: Help with Datasource binding
                jaikiran

                <res-ref-name>java:jboss/datasources/MyDataSource</res-ref-name>   

                That's just a logical name not the real jndi name. So change it to something else (for example, MyDataSource) and use the lookup-name element (available in web-app 3.0 xsd) to point to the jndi name of the datasource:

                 

                <resource-ref id="ResourceRef_1">

                         <res-ref-name>MyDataSource</res-ref-name>        

                         <res-type>javax.sql.DataSource</res-type>

                         <res-auth>Container</res-auth>

                         <res-sharing-scope>Shareable</res-sharing-scope>

                         <!-- Point to the jndi name of the datasource -->

                         <lookup-name>java:jboss/datasources/MyDataSource</lookup-name>

                      </resource-ref>

                • 5. Re: Help with Datasource binding
                  statefan03

                  That worked!   You are a gentlenman, and a scholar!

                   

                  Thank you!

                  • 6. Re: Help with Datasource binding
                    aminjava

                    i am getting similar  error

                    My web app is on 2.4 xsd

                     

                    web.xml :

                    <resource-ref id="dsResourceRef">

                        <res-ref-name>jdbc/ds</res-ref-name>

                        <res-type>javax.sql.DataSo urce</res-type>

                        <res-auth>Container</res-auth>

                      </resource-ref>

                     

                    <resource-ref>

                        <description>Work manager for batch processing</description>

                        <res-ref-name>wm/WorkManager</res-ref-name>

                         <res-auth>Container</res-auth>

                      </resource-ref>

                     

                     

                    jboss-web.xml

                    <resource-ref>

                            <res-ref-name>jdbc/ds</res-ref-name>

                            <res-type>javax.sql.DataSource</res-type>

                            <jndi-name>java:jboss/ds/MyAppDS</jndi-name>

                        </resource-ref>

                     

                    AS7 standalone-full-ha.xml

                    <subsystem xmlns="urn:jboss:domain:datasources:1.0">

                             <datasource jndi-name="java:jboss/ds/MyAppDS" pool-name="OrigixDS" enabled="true" use-java-context="true">

                                  <connection-url>jdbc:oracle:thin:@127.0.0.1:1521:XE</connection-url>

                                   <driver>oracle</driver>

                                   <security>

                                       <user-name>ORGIX</user-name>

                                       <password>ORGIX</password>

                                   </security>

                              </datasource>

                     

                     

                    I get Deployment issue :

                     

                    JBAS014775:    New missing/unsatisfied dependencies:

                          service jboss.naming.context.java.jboss.java:ds.MyAppDS (missing) dependents: [service jboss.naming.context.java.module.origix.origix.env.jdbc.ds]

                          service jboss.naming.context.java.module.MyApp.MyApp.env.WorkManager (missing) dependents: [service jboss.naming.context.java.module.MyApp.MyApp.env.wm.WorkManager]

                    JBAS014776:    Newly corrected services:

                          service jboss.naming.context.java.module.MyApp.MyApp (no longer required)

                     

                     

                    12:35:25,509 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" =>

                    {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.MyApp.MyApp.env.wm.WorkManagerjboss.naming.context.java.module.MyApp.MyApp.env.WorkManagerMissing[jboss.naming.context.java.module.MyApp.MyApp.env.wm.WorkManagerjboss.naming.context.java

                    .module.MyApp.MyAppx.env.WorkManager]","jboss.naming.context.java.module.MyApp.MyApp.env.jdbc.dsjboss.naming.context.java.jboss.java:ds.MyAppMissing[jboss.naming.context.java.module.MyApp.MyApp.env.jdbc.dsjboss.naming.context.java.jboss.java:ds.MyAppDS]"]}}}

                    • 7. Re: Help with Datasource binding
                      jaikiran

                      Which exact version of JBoss AS7 is this and how are you starting it, which configuration file?

                      • 8. Re: Help with Datasource binding
                        aminjava

                        i am using AS7.1.1

                         

                        i am using standalone-full-ha.xml

                        • 9. Re: Help with Datasource binding
                          ananymous7239

                          Hi jaikiran

                           

                          I am facing the similar exception ,i am using Jboss as-7.1.1 final server

                           

                          this is my web.xml

                           

                          <resource-ref>

                                  <description>Database Connection</description>

                                  <res-ref-name>jdbc/mobeereportDatasource</res-ref-name>

                                  <res-type>javax.sql.DataSource</res-type>

                                  <res-auth>Container</res-auth>

                              </resource-ref>

                           

                           

                          and in Jboss-web.xml

                           

                          <jboss-web>

                              <resource-ref>

                                  <res-ref-name>jdbc/mobeereportDatasource</res-ref-name>

                                  <res-type>javax.sql.DataSource</res-type>

                                  <jndi-name>java:mobeereportDatasource</jndi-name>

                                  <res-auth>Container</res-auth>

                              </resource-ref>

                          </jboss-web>

                           

                          this is my standalone.xml

                           

                          <datasources>

                                          <datasource jndi-name="java:/mobeereportDatasource" pool-name="mobeereportDatasource" jta="false" enabled="true" use-java-context="true" use-ccm="false">

                                              <connection-url>jdbc:oracle:thin:@localhost:1521:mobee</connection-url>

                                              <driver>oracle</driver>

                                              

                                               <pool>

                                                   <min-pool-size>10</min-pool-size>

                                                    <max-pool-size>100</max-pool-size>

                                                     <prefill>true</prefill>

                                               </pool>

                                               <security>

                                                      <user-name>mobeeuser</user-name>

                                                      <password>mobeepasswd</password>

                                               </security>

                                               <statement>

                                                       <prepared-statement-cache-size>32</prepared-statement-cache-size>

                                                       <share-prepared-statements/>

                                               </statement>

                                         </datasource>

                                          <drivers>

                                              <driver name="oracle" module="com.oracle">

                                              <driver-class>oracle.jdbc.OracleDriver</driver-class>

                                               <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>

                                              </driver>

                                          </drivers>

                               </datasources>

                           

                           

                          i am getting the following exception:

                           

                          15:54:03,667 ERROR [org.jboss.as] (MSC service thread 1-2) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 77331ms - Started 388 of 699 services (234 services failed or missing dependencies, 76 services are passive or on-demand)

                          15:54:03,864 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "mobeereports.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.mobeereports.mobeereports.env.jdbc.mobeereportDatasourcejboss.naming.context.java.jboss.java:mobeereportDatasourceMissing[jboss.naming.context.java.module.mobeereports.mobeereports.env.jdbc.mobeereportDatasourcejboss.naming.context.java.jboss.java:mobeereportDatasource]"]}

                          15:54:06,483 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment mobeereports.war in 2618ms

                          15:54:06,488 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report

                          JBAS014775:    New missing/unsatisfied dependencies:

                                service jboss.naming.context.java.jboss.java:mobeereportDatasource (missing) dependents: [service jboss.naming.context.java.module.mobeereports.mobeereports.env.jdbc.mobeereportDatasource]

                           

                          15:54:06,510 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.mobeereports.mobeereports.env.jdbc.mobeereportDatasourcejboss.naming.context.java.jboss.java:mobeereportDatasourceMissing[jboss.naming.context.java.module.mobeereports.mobeereports.env.jdbc.mobeereportDatasourcejboss.naming.context.java.jboss.java:mobeereportDatasource]"]}}}

                           

                          could you please help me what need to be change exactly in my xml files.

                           

                          Thanks in advance

                           

                          venu

                          • 10. Re: Help with Datasource binding
                            jaikiran

                            In jboss-web.xml:

                            <jndi-name>java:mobeereportDatasource</jndi-name>

                            That should be:

                             

                            <jndi-name>java:/mobeereportDatasource</jndi-name>

                             

                            The front slash is important.

                            • 11. Re: Help with Datasource binding
                              ananymous7239

                              Thank you so much Jaikiran,i didn't look such a simple mistake ,its working fine.thanks once again