3 Replies Latest reply on Apr 25, 2003 11:25 AM by Marc Sturm

    How to connect 2 datasource?

    jessiewu Newbie

      Could anybody tell me how to configure 2 datasource connection pool in JBoss 3.0.6_tomcat-.1.18?
      And one is Postgre datasource, another is Mysql datasource.
      Especially, I want to know how to write jboss.xml and ejb-jar.xml?
      And should i need jbosscmp-jdbc.xml in META-INF?

        • 1. Re: How to connect 2 datasource?
          Marc Sturm Newbie

          Well, I did it on jboss-3.0.4, it should not be that different. I will try to explain...

          First, in the deploy directory, I created two different *-service.xml files with two different jndi names and mbean names.

          Second, for each ejb-jar.xml, I have a jbosscmp_jdbc.xml file that specifies:
          java:/***
          <datasource-mapping>***</datasource-mapping>

          Then it worked fine. I hope that helps.

          Marc

          • 2. Re: How to connect 2 datasource?
            jessiewu Newbie

            Thank you for your reply. Now I had resolved this problem, but i had a new question. I found Mysql datasource connection was wrong. I can success when i deploy an example, but i failed when i run the client.
            And the error as following:


            09:28:58,301 WARN [TxCapsule] XAException: tx=XidImpl [FormatId=257, GlobalId=y
            01//0, BranchQual=] errorCode=XA_UNKNOWN(0)
            javax.transaction.xa.XAException: Error trying to start local tx: javax.resource
            .ResourceException: SQLException
            at org.jboss.resource.connectionmanager.LocalTxConnectionManager$LocalCo
            nnectionEventListener.start(LocalTxConnectionManager.java:506)
            at org.jboss.tm.TxCapsule.startResource(TxCapsule.java:1232)
            at org.jboss.tm.TxCapsule.enlistResource(TxCapsule.java:726)
            at org.jboss.tm.TransactionImpl.enlistResource(TransactionImpl.java:102)

            at org.jboss.resource.connectionmanager.LocalTxConnectionManager$LocalCo
            nnectionEventListener.enlist(LocalTxConnectionManager.java:320)
            at org.jboss.resource.connectionmanager.LocalTxConnectionManager.managed
            ConnectionReconnected(LocalTxConnectionManager.java:255)
            at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateC
            onnection(BaseConnectionManager2.java:534)
            at org.jboss.resource.connectionmanager.BaseConnectionManager2$Connectio
            nManagerProxy.allocateConnection(BaseConnectionManager2.java:822)
            at org.jboss.resource.adapter.jdbc.local.LocalDataSource.getConnection(L
            ocalDataSource.java:102)
            at examples.ledger_example.LedgerBean.addSavingsAccountActivity(LedgerBe
            an.java:87)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
            java:42)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
            sorImpl.java:28)
            at java.lang.reflect.Method.invoke(Method.java:327)
            at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(St
            atefulSessionContainer.java:824)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.
            java:130)
            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo
            ke(CachedConnectionInterceptor.java:186)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
            rceptor.java:107)
            at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxI
            nterceptorBMT.java:144)
            at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:6
            2)
            at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(State
            fulSessionInstanceInterceptor.java:268)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
            at org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContaine
            r.java:380)
            at org.jboss.ejb.Container.invoke(Container.java:712)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
            at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
            382)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
            java:42)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
            sorImpl.java:28)
            at java.lang.reflect.Method.invoke(Method.java:327)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:264)
            at sun.rmi.transport.Transport$1.run(Transport.java:151)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:147)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
            63)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
            .java:704)
            at java.lang.Thread.run(Thread.java:539)

            Could you tell me what's wrong with it? And how can i resolve it ? This problem had bored me for a long time.

            • 3. Re: How to connect 2 datasource?
              Marc Sturm Newbie

              Sorry, I have not worked with mySQL, can't help. Quickly, I think it could be a transaction issue.

              Marc