In oracle I have two separate databases I need to pull information from. So I created a second data source in hibernate.
Here is my comfiguration:
dev.ds.xml
Code:
<datasources>
<local-tx-datasource>
<jndi-name>aggDatasource</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:oracle:thin:@ipaddress:port:tstdwrpt</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name></user-name>
<password></password>
</local-tx-datasource>
<local-tx-datasource>
<jndi-name>dmbDatasource</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:oracle:thin:@ipaddress:port:test10</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name></user-name>
<password></password>
</local-tx-datasource>
</datasources>
components.xml
Code:
<persistence:managed-persistence-context
auto-create="true" name="entityManager" persistence-unit-jndi-name="java:/dmbEntityManagerFactory" />
<persistence:managed-persistence-context
auto-create="true" name="aggEntityManager" persistence-unit-jndi-name="java:/aggEntityManagerFactory" />
persistence.xml
Code:
<persistence-unit name="agg">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>aggDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.default_schema" value=""/>
<property name="hibernate.session_factory_name" value="aggSessionFactory" />
<property name="jboss.entity.manager.factory.jndi.name" value="java:/aggEntityManagerFactory"/>
</properties>
</persistence-unit>
<persistence-unit name="dmb">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>dmbDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.default_schema" value=""/>
<property name="hibernate.session_factory_name" value="dmbSessionFactory" />
<property name="jboss.entity.manager.factory.jndi.name" value="java:/dmbEntityManagerFactory"/>
</properties>
</persistence-unit>
The aggDatasource is the one I'm getting the error on.
Here is a start to that error:
11:11:03,244 WARN [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] Adding multiple last resources is disallowed. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@419a00
11:11:03,291 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
11:11:03,291 ERROR [JDBCExceptionReporter] Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -7ffe2fd9:127a:4cfcf85a:13d status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -7ffe2fd9:127a:4cfcf85a:13d status: ActionStatus.ABORT_ONLY >))
11:11:03,307 ERROR [TxPolicy] javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Cannot open connection
11:11:03,307 SEVERE [application] javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Cannot open connection
javax.faces.el.EvaluationException: javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Cannot open connection