1 Reply Latest reply on Aug 10, 2010 1:14 PM by Peter Brewer

    Problem with connection two different databases

    Enrico Rossini Newbie
      Hello friends, this is my first post :) and I have a problem :(

      In my project I need to connect two different database on MySql with names esiahc_rimpdm15 and esiahc_ext. I configured datasource.xml with this values:

      <datasources>  
         <local-tx-datasource>
            <jndi-name>AllarmiEARDatasource</jndi-name>
            <connection-url>jdbc:mysql://localhost/esiahc_ext</connection-url>
            <driver-class>com.mysql.jdbc.Driver</driver-class>
            <user-name>myuser</user-name>
            <password>mypassword</password>
         </local-tx-datasource>
        
         <local-tx-datasource>
            <jndi-name>DictionaryDatasource</jndi-name>
            <connection-url>jdbc:mysql://localhost/esiahc_rimpdm15</connection-url>
            <driver-class>com.mysql.jdbc.Driver</driver-class>
            <user-name>myuser</user-name>
            <password>mypassword</password>
         </local-tx-datasource>
      </datasources>




      I configured persistence.xml with this values:

      <persistence-unit name="AllarmiEAR" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/AllarmiEARDatasource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
               <property name="hibernate.hbm2ddl.auto" value="validate"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/AllarmiEAREntityManagerFactory"/>
               <property name="jboss.entity.manager.jndi.name" value="java:/AllarmiEAREntityManager" />
            </properties>
         </persistence-unit>
        
         <persistence-unit name="DictionaryPer" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/DictionaryDatasource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
               <property name="hibernate.hbm2ddl.auto" value="validate"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/DictionaryPUEntityManagerFactory"/>
               <property name="jboss.entity.manager.jndi.name" value="java:/DictionaryPUEntityManager" />
            </properties>
         </persistence-unit>



      Finally, I configured component.xml:

      <persistence:managed-persistence-context auto-create="true"
        name="entityManager" persistence-unit-jndi-name="java:/AllarmiEAREntityManagerFactory"/>
      <persistence:managed-persistence-context auto-create="true"
        name="entityManagerDictionary" persistence-unit-jndi-name="java:/AllarmiEAREntityManagerFactoryDictionaryPU"/>


      When I start JBoss it says this:

      17:42:01,090 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] Incomplete Deployment listing:

      --- MBeans waiting for other MBeans ---
      ObjectName: persistence.units:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,unitName=AllarmiEAR
        State: FAILED
        Reason: javax.persistence.PersistenceException: [PersistenceUnit: AllarmiEAR] Unable to build EntityManagerFactory
        I Depend On:
          jboss.jca:service=DataSourceBinding,name=AllarmiEARDatasource
        Depends On Me:
          jboss.j2ee:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,name=GestioneAllarmeAction,service=EJB3
          jboss.j2ee:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,name=MonitorManagerBean,service=EJB3

      ObjectName: persistence.units:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,unitName=DictionaryPer
        State: FAILED
        Reason: javax.persistence.PersistenceException: [PersistenceUnit: DictionaryPer] Unable to build EntityManagerFactory
        I Depend On:
          jboss.jca:service=DataSourceBinding,name=DictionaryDatasource

      ObjectName: jboss.j2ee:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,name=GestioneAllarmeAction,service=EJB3
        State: NOTYETINSTALLED
        I Depend On:
          persistence.units:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,unitName=AllarmiEAR

      ObjectName: jboss.j2ee:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,name=MonitorManagerBean,service=EJB3
        State: NOTYETINSTALLED
        I Depend On:
          persistence.units:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,unitName=AllarmiEAR

      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: persistence.units:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,unitName=AllarmiEAR
        State: FAILED
        Reason: javax.persistence.PersistenceException: [PersistenceUnit: AllarmiEAR] Unable to build EntityManagerFactory
        I Depend On:
          jboss.jca:service=DataSourceBinding,name=AllarmiEARDatasource
        Depends On Me:
          jboss.j2ee:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,name=GestioneAllarmeAction,service=EJB3
          jboss.j2ee:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,name=MonitorManagerBean,service=EJB3

      ObjectName: persistence.units:ear=CATALOG_SERVER.ear,jar=AllarmiEAR.jar,unitName=DictionaryPer
        State: FAILED
        Reason: javax.persistence.PersistenceException: [PersistenceUnit: DictionaryPer] Unable to build EntityManagerFactory
        I Depend On:
          jboss.jca:service=DataSourceBinding,name=DictionaryDatasource


      Can you help me? Thank you in advance.