5 Replies Latest reply on Feb 16, 2007 10:49 AM by Alessandro Ilardo

    multiple datasource

    Alessandro Ilardo Newbie

      Hi there,
      I'm new with Jboss and I'm trying to understand how to configure multiple datasource based on different databases. I've already gone trough the jboss.com docs, but onestly it didn't help me much.
      I'm now working with JBoss 4.0.5 and MySQL 5 (but I'd like implement Oracle too).

      Following http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpAMysqlDatasource I've been able to run my entity bean, however I had to replace the DefaultDS hsqldb with MySQL and this is not exactly what I wanted to achieve.
      So, I'm probably missing something. Would you have a look on what I did and tell me if I need further configurations?

      * add the mysql driver
      * replaced the hsqldb-ds.xml with the new edited mysql-ds.xml

      <datasources>
       <local-tx-datasource>
       <jndi-name>DefaultDS</jndi-name>
       <connection-url>jdbc:mysql://127.0.0.2:3306/tmp</connection-url>
       <driver-class>org.gjt.mm.mysql.Driver</driver-class>
       <user-name>user</user-name>
       <password>temp</password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
       </datasources>


      * replaced the ../jms/hsqldb-jdbc2-service.xml with ../jms/mysql-jdbc2-service.xml
      <server>
       <mbean code="org.jboss.mq.server.jmx.DestinationManager" name="jboss.mq:service=DestinationManager">
       <depends optional-attribute-name="MessageCache">jboss.mq:service=MessageCache</depends>
       <depends optional-attribute-name="PersistenceManager">jboss.mq:service=PersistenceManager</depends>
       <depends optional-attribute-name="StateManager">jboss.mq:service=StateManager</depends>
       </mbean>
       <mbean code="org.jboss.mq.server.MessageCache"
       name="jboss.mq:service=MessageCache">
       <attribute name="HighMemoryMark">50</attribute>
       <attribute name="MaxMemoryMark">60</attribute>
       <attribute name="CacheStore">jboss.mq:service=PersistenceManager</attribute>
       </mbean>
       <mbean code="org.jboss.mq.pm.jdbc2.PersistenceManager"
       name="jboss.mq:service=PersistenceManager">
       <depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
       <attribute name="SqlProperties">
       ...
       ...


      * modified the ejb-jar.xml in my module

      <resource-ref>
       <description>jdbc:mysql://127.0.0.2:3306/tmp</description>
       <res-ref-name>jdbc/DefaultDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       <res-sharing-scope>Shareable</res-sharing-scope>
       </resource-ref>


      * edit the entity bean method
      private javax.sql.DataSource getSavingsAccountDB() throws javax.naming.NamingException {
       javax.naming.Context c = new javax.naming.InitialContext();
       return (javax.sql.DataSource) c.lookup("java:comp/env/jdbc/DefaultDS");
       }
      



      So, as I sayd the entity bean correctly works, but on JBoss startup I now get an error
      19:12:20,488 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

      --- MBeans waiting for other MBeans ---
      ObjectName: jboss.mq:service=InvocationLayer,type=HTTP
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=Invoker
      jboss.web:service=WebServer

      ObjectName: jboss.mq.destination:service=Topic,name=testTopic
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager
      jboss.mq:service=SecurityManager

      ObjectName: jboss.mq.destination:service=Topic,name=securedTopic
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager
      jboss.mq:service=SecurityManager

      ObjectName: jboss.mq.destination:service=Topic,name=testDurableTopic
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager
      jboss.mq:service=SecurityManager

      ObjectName: jboss.mq.destination:service=Queue,name=testQueue
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager
      jboss.mq:service=SecurityManager

      ObjectName: jboss.mq.destination:service=Queue,name=A
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager

      ObjectName: jboss.mq.destination:service=Queue,name=B
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager

      ObjectName: jboss.mq.destination:service=Queue,name=C
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager

      ObjectName: jboss.mq.destination:service=Queue,name=D
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager

      ObjectName: jboss.mq.destination:service=Queue,name=ex
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager

      ObjectName: jboss.mq:service=Invoker
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=TracingInterceptor
      jboss:service=Naming
      Depends On Me:
      jboss.mq:service=InvocationLayer,type=HTTP
      jboss.mq:service=InvocationLayer,type=JVM
      jboss.mq:service=InvocationLayer,type=UIL2

      ObjectName: jboss.mq:service=TracingInterceptor
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=SecurityManager
      Depends On Me:
      jboss.mq:service=Invoker

      ObjectName: jboss.mq:service=SecurityManager
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager
      Depends On Me:
      jboss.mq.destination:service=Topic,name=testTopic
      jboss.mq.destination:service=Topic,name=securedTopic
      jboss.mq.destination:service=Topic,name=testDurableTopic
      jboss.mq.destination:service=Queue,name=testQueue
      jboss.mq:service=TracingInterceptor
      jboss.mq.destination:service=Queue,name=DLQ

      ObjectName: jboss.mq.destination:service=Queue,name=DLQ
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=DestinationManager
      jboss.mq:service=SecurityManager

      ObjectName: jboss.mq:service=InvocationLayer,type=JVM
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=Invoker

      ObjectName: jboss.mq:service=InvocationLayer,type=UIL2
      State: CONFIGURED
      I Depend On:
      jboss.mq:service=Invoker

      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.mq:service=DestinationManager
      State: NOTYETINSTALLED
      Depends On Me:
      jboss.mq.destination:service=Topic,name=testTopic
      jboss.mq.destination:service=Topic,name=securedTopic
      jboss.mq.destination:service=Topic,name=testDurableTopic
      jboss.mq.destination:service=Queue,name=testQueue
      jboss.mq.destination:service=Queue,name=A
      jboss.mq.destination:service=Queue,name=B
      jboss.mq.destination:service=Queue,name=C
      jboss.mq.destination:service=Queue,name=D
      jboss.mq.destination:service=Queue,name=ex
      jboss.mq:service=SecurityManager
      jboss.mq.destination:service=Queue,name=DLQ




      I was not able to find the reason, but it started after I replaced the DefaultDS with MySQL.

      Back to my configuration, how can I set up multiple datasource?

      Thank you in advance.

        • 1. Re: multiple datasource
          Weston M. Price Master

          If you simply want to use MySQL (or any other RDMBS) provider you simply need to create the datasource for that provider. Replacing the DefaultDS datasource would be necessary if you wanted to replace the persistence mechanism used interally by JBoss for JMS and other services.

          So, to create a datasource the steps are usually straightforward:

          1) Look in your <jboss-home/docs/examples/jca directory and see if there is a sample *-ds.xml for your database. If so, simply copy this file, replace the values with your specific values and place the file in the <jboss-home>/server/<server-config>/deploy directory. Note, any number of datasources can be specified in the *-ds.xml file so it is not limited to one file->onedatasource

          2) If there is not an example, simply copy one of the example files and replace the values with those from your JDBC driver documentation.

          More on JDBC configuration can be found on the JCA part of our Wiki:

          http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources


          • 2. Re: multiple datasource
            Alessandro Ilardo Newbie

            thanks for your reply,
            I did what you said as first attempt, but my bean kept pointing to the hsqldb, that's why I replaced the default.

            • 3. Re: multiple datasource
              Weston M. Price Master

              Ok, so the problem is in your resource-ref

              When you deploy a seperate datasource, your resorce-ref needs to point to your new datasource, not DefaultDS.

              Your configuration

              <resource-ref>
               <description>jdbc:mysql://127.0.0.2:3306/tmp</description>
               <res-ref-name>jdbc/DefaultDS</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
               <res-sharing-scope>Shareable</res-sharing-scope>
               </resource-ref>
              


              Should be rewritten as

              <resource-ref>
               <description>jdbc:mysql://127.0.0.2:3306/tmp</description>
              
               <res-ref-name>jdbc/SOME-NEW_NAME-FOR-MY-DS</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
               <res-sharing-scope>Shareable</res-sharing-scope>
               </resource-ref>
              
              


              The resource-ref name is simply a logical binding used in your code to avoid having to hardcode resource-JNDI names.

              Now you simply need a jboss.xml file to bind the resource-ref to the actual JNDI name in your *-ds.xml file:

               <resource-ref>
               <res-ref-name >jdbc/SOME-NEW_NAME-FOR-MY-DS</res-ref-name>
               <resource-name>THE-ACTUAL-JNDI-NAME</resource-name>
               </resource-ref>
              


              The jboss.xml file should go in the META-INF directory of your EJB jar file. My suggestion would be to start with a fresh install of JBoss, make the changes and redeploy.

              • 4. Re: multiple datasource
                Alessandro Ilardo Newbie

                I tried to implement your solution, but it is still not working.
                What I've done:
                - restored the original configuration for the DefaultDS (../jboss-4.0.5.GA/server/default/deploy/jms/hsqldb-jdbc2-service.xml, ../jboss-4.0.5.GA/server/default/deploy/hsqldb-ds.xml )

                - deleted the mysql-jdbc2-service.xml from ../jboss-4.0.5.GA/server/default/deploy/jms/

                - added a new file copied form the examples (../jboss-4.0.5.GA/server/default/deploy/mysql-ds.xml)

                <datasources>
                 <local-tx-datasource>
                 <jndi-name>savingsExampleDS</jndi-name>
                 <connection-url>jdbc:mysql://127.0.0.2:3306/tmp</connection-url>
                 <driver-class>org.gjt.mm.mysql.Driver</driver-class>
                 <user-name>alessandro</user-name>
                 <password>*************</password>
                 <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
                 <!-- should only be used on drivers after 3.22.1 with "ping" support
                 <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
                 -->
                 <!-- sql to call when connection is created
                 <new-connection-sql>some arbitrary sql</new-connection-sql>
                 -->
                 <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
                 <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
                 -->
                 <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
                 <metadata>
                 <type-mapping>mySQL</type-mapping>
                 </metadata>
                 </local-tx-datasource>
                </datasources>
                


                - edit three files related to the JDBC connection in my bean
                ejb-jar.xml
                <?xml version="1.0" encoding="UTF-8"?>
                <ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
                 <display-name>SavingsAccountEJB</display-name>
                 <enterprise-beans>
                 <entity>
                 <display-name>SavingsAccountEB</display-name>
                 <ejb-name>SavingsAccountBean</ejb-name>
                 <home>bank.SavingsAccountRemoteHome</home>
                 <remote>bank.SavingsAccountRemote</remote>
                 <ejb-class>bank.SavingsAccountBean</ejb-class>
                 <persistence-type>Bean</persistence-type>
                 <prim-key-class>java.lang.String</prim-key-class>
                 <reentrant>false</reentrant>
                 <resource-ref>
                 <description>jdbc:mysql://127.0.0.2:3306/tmp [alessandro on Default schema]</description>
                 <res-ref-name>jdbc/savingsExampleDS</res-ref-name>
                 <res-type>javax.sql.DataSource</res-type>
                 <res-auth>Container</res-auth>
                 <res-sharing-scope>Shareable</res-sharing-scope>
                 </resource-ref>
                 </entity>
                 </enterprise-beans>
                 <assembly-descriptor>
                 <container-transaction>
                 <method>
                 <ejb-name>SavingsAccountBean</ejb-name>
                 <method-name>*</method-name>
                 </method>
                 <trans-attribute>Required</trans-attribute>
                 </container-transaction>
                 </assembly-descriptor>
                 </ejb-jar>

                jboss.xml
                <?xml version="1.0" encoding="UTF-8"?>
                <jboss>
                 <enterprise-beans>
                 <ejb>
                 <ejb-name>SavingsAccountBean</ejb-name>
                 <jndi-name>ejb/SavingsAccountBean</jndi-name>
                 <resource-ref>
                 <res-ref-name>jdbc/savingsExampleDS</res-ref-name>
                 <resource-name>savingsExampleDS</resource-name>
                 </resource-ref>
                 </ejb>
                 </enterprise-beans>
                </jboss>

                SavingsAccountBean.java
                private javax.sql.DataSource getSavingsAccountDB() throws javax.naming.NamingException {
                 javax.naming.Context c = new javax.naming.InitialContext();
                 return (javax.sql.DataSource) c.lookup("java:comp/env/jdbc/savingsExampleDS");
                 }


                When I run the client I get this error from both Jboss and client

                09:15:38,165 ERROR [LogInterceptor] EJBException in method: public abstract bank.SavingsAccountRemote bank.SavingsAccountRemoteHome.create(java.lang.String,java.lang.String,java.lang.String,java.math.BigDecimal) throws javax.ejb.CreateException,java.rmi.RemoteException:
                javax.ejb.EJBException: Unable to connect to database. jdbc not bound
                at bank.SavingsAccountBean.makeConnection(SavingsAccountBean.java:218)
                at bank.SavingsAccountBean.insertRow(SavingsAccountBean.java:280)
                at bank.SavingsAccountBean.ejbCreate(SavingsAccountBean.java:149)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


                and on the jboss init (which I'm not sure has something to do with my problem)

                09:15:22,109 WARN [StatelessSessionContainer] Could not restore ejb timers
                javax.management.RuntimeMBeanException
                at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:176)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:163)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.ejb.Container.restoreTimers(Container.java:766)
                at org.jboss.ejb.SessionContainer.startService(SessionContainer.java:410)
                at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                at $Proxy0.start(Unknown Source)
                at org.jboss.system.ServiceController.start(ServiceController.java:417)
                at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                at $Proxy59.start(Unknown Source)
                at org.jboss.ejb.EjbModule.startService(EjbModule.java:429)
                at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                at $Proxy0.start(Unknown Source)
                at org.jboss.system.ServiceController.start(ServiceController.java:417)
                at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                at $Proxy26.start(Unknown Source)
                at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:662)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
                at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
                at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
                at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
                at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                at $Proxy27.start(Unknown Source)
                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                at $Proxy8.deploy(Unknown Source)
                at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
                at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
                at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                at $Proxy0.start(Unknown Source)
                at org.jboss.system.ServiceController.start(ServiceController.java:417)
                at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                at $Proxy4.start(Unknown Source)
                at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                at $Proxy5.deploy(Unknown Source)
                at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
                at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
                at org.jboss.Main.boot(Main.java:200)
                at org.jboss.Main$1.run(Main.java:490)
                at java.lang.Thread.run(Thread.java:595)
                Caused by: java.lang.NullPointerException
                at org.jboss.ejb.txtimer.DatabasePersistencePolicy.listTimerHandles(DatabasePersistencePolicy.java:164)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                at $Proxy25.listTimerHandles(Unknown Source)
                at org.jboss.ejb.txtimer.EJBTimerServiceImpl.restoreTimers(EJBTimerServiceImpl.java:408)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                ... 141 more
                09:15:22,122 INFO [EJBDeployer] Deployed: file:/etc/jboss-4.0.5.GA/server/default/tmp/deploy/tmp45061converterapp.ear-contents/ConverterApp-EJBModule.jar
                09:15:22,306 INFO [TomcatDeployer] deploy, ctxPath=/ConverterApp-WebModule, warUrl=.../tmp/deploy/tmp45061converterapp.ear-contents/ConverterApp-WebModule-exp.war/
                09:15:23,297 INFO [EARDeployer] Started J2EE application: file:/etc/jboss-4.0.5.GA/server/default/deploy/converterapp.ear
                09:15:23,299 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

                --- MBeans waiting for other MBeans ---
                ObjectName: jboss.ejb:service=EJBTimerService,persistencePolicy=database
                State: CONFIGURED
                I Depend On:
                jboss.jca:service=DataSourceBinding,name=DefaultDS

                ObjectName: jboss.mq:service=InvocationLayer,type=HTTP
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=Invoker
                jboss.web:service=WebServer

                ObjectName: jboss:service=KeyGeneratorFactory,type=HiLo
                State: CONFIGURED
                I Depend On:
                jboss:service=TransactionManager
                jboss.jca:service=DataSourceBinding,name=DefaultDS

                ObjectName: jboss.mq:service=StateManager
                State: CONFIGURED
                I Depend On:
                jboss.jca:service=DataSourceBinding,name=DefaultDS

                ObjectName: jboss.mq.destination:service=Topic,name=testTopic
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager
                jboss.mq:service=SecurityManager

                ObjectName: jboss.mq.destination:service=Topic,name=securedTopic
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager
                jboss.mq:service=SecurityManager

                ObjectName: jboss.mq.destination:service=Topic,name=testDurableTopic
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager
                jboss.mq:service=SecurityManager

                ObjectName: jboss.mq.destination:service=Queue,name=testQueue
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager
                jboss.mq:service=SecurityManager

                ObjectName: jboss.mq.destination:service=Queue,name=A
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager

                ObjectName: jboss.mq.destination:service=Queue,name=B
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager

                ObjectName: jboss.mq.destination:service=Queue,name=C
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager

                ObjectName: jboss.mq.destination:service=Queue,name=D
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager

                ObjectName: jboss.mq.destination:service=Queue,name=ex
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager

                ObjectName: jboss.mq:service=Invoker
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=TracingInterceptor
                jboss:service=Naming
                Depends On Me:
                jboss.mq:service=InvocationLayer,type=HTTP
                jboss.mq:service=InvocationLayer,type=JVM
                jboss.mq:service=InvocationLayer,type=UIL2

                ObjectName: jboss.mq:service=TracingInterceptor
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=SecurityManager
                Depends On Me:
                jboss.mq:service=Invoker

                ObjectName: jboss.mq:service=SecurityManager
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager
                Depends On Me:
                jboss.mq.destination:service=Topic,name=testTopic
                jboss.mq.destination:service=Topic,name=securedTopic
                jboss.mq.destination:service=Topic,name=testDurableTopic
                jboss.mq.destination:service=Queue,name=testQueue
                jboss.mq:service=TracingInterceptor
                jboss.mq.destination:service=Queue,name=DLQ

                ObjectName: jboss.mq.destination:service=Queue,name=DLQ
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=DestinationManager
                jboss.mq:service=SecurityManager

                ObjectName: jboss.mq:service=InvocationLayer,type=JVM
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=Invoker

                ObjectName: jboss.mq:service=InvocationLayer,type=UIL2
                State: CONFIGURED
                I Depend On:
                jboss.mq:service=Invoker

                --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
                ObjectName: jboss.jca:service=DataSourceBinding,name=DefaultDS
                State: NOTYETINSTALLED
                Depends On Me:
                jboss.ejb:service=EJBTimerService,persistencePolicy=database
                jboss:service=KeyGeneratorFactory,type=HiLo
                jboss.mq:service=StateManager

                ObjectName: jboss.mq:service=DestinationManager
                State: NOTYETINSTALLED
                Depends On Me:
                jboss.mq.destination:service=Topic,name=testTopic
                jboss.mq.destination:service=Topic,name=securedTopic
                jboss.mq.destination:service=Topic,name=testDurableTopic
                jboss.mq.destination:service=Queue,name=testQueue
                jboss.mq.destination:service=Queue,name=A
                jboss.mq.destination:service=Queue,name=B
                jboss.mq.destination:service=Queue,name=C
                jboss.mq.destination:service=Queue,name=D
                jboss.mq.destination:service=Queue,name=ex
                jboss.mq:service=SecurityManager
                jboss.mq.destination:service=Queue,name=DLQ


                09:15:23,539 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
                09:15:23,810 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
                09:15:23,820 INFO [JkMain] Jk running ID=0 time=0/28 config=null
                09:15:23,846 INFO [Server] JBoss (MX MicroKernel) [4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)] Started in 40s:110ms

                can you tell me your opinion? Thanks again.

                • 5. Re: multiple datasource
                  Alessandro Ilardo Newbie

                  solved it out!

                  first of all, I decided to reinstall JBoss, because it kept giving me that error which I didn't know where was coming from and that didn't make me happy.

                  So basically the jboss.xml should had

                  <resource-name>java:savingsExampleDS</resource-name>

                  instead

                  <resource-name>savingsExampleDS</resource-name>

                  that's why it was keeping point to the default.
                  http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoICreateAResourceRef