7 Replies Latest reply on May 6, 2011 9:46 AM by amberjboss1999

    Jboss6: Unable to get managed connection for jdbc with Spring

    amberjboss1999

      I am migrating an exisiting web app (war) from apache tomcat 6 to jboss6.

      I keep getting:

      DEPLOYMENTS IN ERROR:

        Deployment "vdpDS" is in error due to the following reason(s): ** NOT FOUND Depends on 'vdpDS' **

       

      1./WEB-INF/applicationContext:

      <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/vdpDS" resource-ref="true" expected-type="javax.sql.DataSource" />

       

      2.WEB-INF/web.xml

      <resource-ref>

              <res-ref-name>vdpDS</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              <res-sharing-scope>Shareable</res-sharing-scope>
          </resource-ref>

       

      3.WEB-INF/jboss-web.xml

      <jboss-web>

      <resource-ref>

      <res-ref-name>vdpDS</res-ref-name>

      <jndi-name>vdpDS</jndi-name>

      </resource-ref>

      </jboss-web>

       

      4. i think this is for tomcat, but it's there anyway:

      META-INF/context.xml

      <context>

          <ResourceLink global="vdpDS" name="java:comp/env/vdpDS" type="javax.sql.DataSource"/>

      </context>

       

      5. my vdpDS-ds.xml, under deploy/<vdpDS> subfolder:

      <local-tx-datasource>

                              <jndi-name>vdpDS</jndi-name>

                              <driver-class>com.inet.tds.TdsDriver</driver-class>-->

                              <connection-url>jdbc:jtds:sqlserver://server:port;database=db</connection-url>

                              <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>

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

                              <password>pwd</password>

              </local-tx-datasource>

       

      6. I also dropped the jdbc.jar in the lib/<vdpDS> subfolder

      subfolder, using jtds1.2.3.jar

       

      This setup was working for tomcat6.

      Can someone help me solve this datasource not found error, please?



        • 1. Jboss6: Unable to get managed connection for jdbc with Spring
          amberjboss1999

          sorry, I forgot to comment out this line <!--<driver-class>com.inet.tds.TdsDriver</driver-class>-->

          alas the change, it's still not working, getting the same error.

          • 2. Jboss6: Unable to get managed connection for jdbc with Spring
            jaikiran

            amber jboss1999 wrote:

             


            3.WEB-INF/jboss-web.xml

            <jboss-web>

            <resource-ref>

            <res-ref-name>vdpDS</res-ref-name>

            <jndi-name>vdpDS</jndi-name>

            </resource-ref>

            </jboss-web>

             

            The jndi-name should be:

             

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

             

            Also, please post the entire exception stacktrace if you still run into problems.

            • 3. Re: Jboss6: Unable to get managed connection for jdbc with Spring
              amberjboss1999

              thanks in advance jaikiran_pai.

              I makde that change to add java: and still got the error, here is the full stacktrace:

               

              ERROR [ProfileServiceBootstrap] Failed to load profile:: org.jboss.deployers.client.spi.IncompleteDeploymen

              tException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

               

               

              DEPLOYMENTS MISSING DEPENDENCIES:

                Deployment "jboss-switchboard:appName=<webroot>,module=<webroot>" is missing the following dependencies:

                  Dependency "jboss.jca:name=internal/<webroot>/<webroot>/env/vdpDS,service=DataSourceBinding" (should be in state "Installed", bu

              t is actually in state "** NOT FOUND Depends on 'jboss.jca:name=internal/<webroot>/<webroot>/env/vdpDS,service=DataSourceBinding',wh

              enRequired=MapControllerStateModel$ControllerStateWrapper@1885dd3{Installed},dependentState=MapControllerStateModel$Cont

              rollerStateWrapper@1885dd3{Installed} **")

                Deployment "jboss.web.deployment:war=/<webroot>" is missing the following dependencies:

                  Dependency "jboss-switchboard:appName=<webroot>,module=<webroot>" (should be in state "Installed", but is actually in state "Dep

              loy")

               

               

              DEPLOYMENTS IN ERROR:

                Deployment "jboss.jca:name=internal/<webroot>/<webroot>/env/vdpDS,service=DataSourceBinding" is in error due to the following reas

              on(s): ** NOT FOUND Depends on 'jboss.jca:name=internal/<webroot>/<webroot>/env/vdpDS,service=DataSourceBinding',whenRequired=MapCon

              trollerStateModel$ControllerStateWrapper@1885dd3{Installed},dependentState=MapControllerStateModel$ControllerStateWrappe

              r@1885dd3{Installed} **

               

               

                      at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1228) [:2.2.0.GA]

                      at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:905) [:2.2.0.GA]

                      at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:87)

              [:6.0.0.Final]

                      at org.jboss.profileservice.deployment.ProfileDeployerPluginRegistry.checkAllComplete(ProfileDeployerPluginRegis

              try.java:107) [:0.2.2]

                      at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootst

              rap.java:135) [:6.0.0.Final]

                      at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootst

              rap.java:56) [:6.0.0.Final]

                      at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap

              -impl-base.jar:2.1.0-alpha-5]

                      at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-boots

              trap-impl-base.jar:2.1.0-alpha-5]

                      at java.lang.Thread.run(Thread.java:662) [:1.6.0_23-ea]

               

               

               

              I swapped out the web context root with <webroot> in this post.

              • 4. Re: Jboss6: Unable to get managed connection for jdbc with Spring
                amberjboss1999

                Sorry, I should've only added java: in jndi-name and not res-ref-name.

                 

                This allows me to deploy the app fine. But it failed to create a db connection when I actually query the DB(run the app): with Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: net.sourceforge.jtds.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver)

                 

                This is getting to be very frustrating, my jtds.jar is under <server>/lib/<subfolder>, and the deployed war is under <server>/deploy/<subfolder>; I verified the driver class is there. I will load jtds.jar as a compile time dependency and see if that solves the problem.

                 

                 

                Here is the full stack trace,

                org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: net.sourceforge.jtds.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver))

                          at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:261) [:6.0.0.Final]

                          at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:215) [:6.0.0.Final]

                          at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:648) [:6.0.0.Final]

                          at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:272) [:6.0.0.Final]

                          at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:690) [:6.0.0.Final]

                          at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:403) [:6.0.0.Final]

                          at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:414) [:6.0.0.Final]

                          at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496) [:6.0.0.Final]

                          at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941) [:6.0.0.Final]

                          at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89) [:6.0.0.Final]

                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23-ea]

                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23-ea]

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23-ea]

                          at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23-ea]

                          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) [:3.0.5.RELEASE]

                          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196) [:3.0.5.RELEASE]

                          at $Proxy162.getConnection(Unknown Source)          at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:572) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:661) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:701) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:177) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:190) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForLong(NamedParameterJdbcTemplate.java:208) [:3.0.5.RELEASE]

                          at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForLong(NamedParameterJdbcTemplate.java:213)

                ........

                • 5. Re: Jboss6: Unable to get managed connection for jdbc with Spring
                  amberjboss1999

                  ok. The app seems to be working after I changed jtds.jar to compile time dependency and removed the server/lib/<subfolder>/jtds.jar from server path. But it's not perfect, b/c jBoss6 is still throwing exceptions, saying

                  "

                  Caused by: org.jboss.resource.JBossResourceException: Apparently wrong driver class specified for URL: class: net.sourceforge.jtds.jdbc.Driver, url: jdbc:jtds:sqlserver://<server>:<port>;database=<db>".

                   

                  If I used provided scope and put the jar back in lib/<subfolder>, I'd get ClassNotFoundException. It's WEIRD.

                   

                  Any insight is appreciated, jaikiran pai!

                  • 6. Re: Jboss6: Unable to get managed connection for jdbc with Spring
                    jaikiran

                    amber jboss1999 wrote:

                     

                    If I used provided scope and put the jar back in lib/<subfolder>, I'd get ClassNotFoundException. It's WEIRD.

                     

                     

                    The driver jar should be in JBOSS_HOME/server/<servername>/lib folder (and not any subfolder).

                     

                     

                    amber jboss1999 wrote:

                    . But it's not perfect, b/c jBoss6 is still throwing exceptions, saying

                    "

                    Caused by: org.jboss.resource.JBossResourceException: Apparently wrong driver class specified for URL: class: net.sourceforge.jtds.jdbc.Driver, url: jdbc:jtds:sqlserver://<server>:<port>;database=<db>".

                     

                    Please post the entire exception stacktrace and the latest *-ds.xml file that you are using.

                    • 7. Re: Jboss6: Unable to get managed connection for jdbc with Spring
                      amberjboss1999

                      I apologize for not updating promptly.

                      I got a little flustered with my last reply. But basically once I revert the depedency back to provided scope, and remove it from compile time depedency; it all worked! Yay!

                      BTW, I do have the jar under a subfolder (for ease of mgmt) of customized jars.

                      Thanks!