Я пытаюсь создать менеджер транзакций и использовать его с Hibernate для Oracle.
Мой файл persistence.xml:
<persistence-unit name="org.drools.persistence.jpa"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/testDS1</jta-data-source>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.jndi.class" value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup" />
</properties>
</persistence-unit>
В applicationContext.xml весны я добавил:
<bean id="dataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close">
<property name="className" value="oracle.jdbc.xa.client.OracleXADataSource" />
<property name="uniqueName" value="jdbc/testDS1" />
<property name="minPoolSize" value="1" />
<property name="maxPoolSize" value="5" />
<property name="driverProperties">
<props>
<prop key="URL">myURL</prop>
<prop key="user">username</prop>
<prop key="password">password</prop>
</props>
</property>
</bean>
<bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="bitronixTransactionManager"/>
<property name="userTransaction" ref="bitronixTransactionManager"/>
</bean>
<bean id="bitronixTransactionManager" factory-method="getTransactionManager"
class="bitronix.tm.TransactionManagerServices" depends-on="dataSource,txManager"
destroy-method="shutdown"/>
Однако, когда я бегу:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
Я получаю исключение:
Caused by: org.hibernate.HibernateException: Could not find datasource: jdbc/testDS1
Исключение составляет ds = (DataSource ) NamingHelper.getInitialContext(props).lookup(jndiName);
файла Hibernate.
В чем может быть проблема?
Как Hibernate знает, что относится к бобу весны txManager
?