Note that there are some explanatory texts on larger screens.

plurals
  1. POBitronix + Spring + Hibernate + Persistence
    primarykey
    data
    text
    <p>I am trying to create transaction manager and use it with Hibernate for Oracle.</p> <p>My persistence.xml file is:</p> <pre><code>&lt;persistence-unit name="org.drools.persistence.jpa" transaction-type="JTA"&gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;jta-data-source&gt;jdbc/testDS1&lt;/jta-data-source&gt; &lt;class&gt;org.drools.persistence.session.SessionInfo&lt;/class&gt; &lt;class&gt;org.jbpm.persistence.processinstance.ProcessInstanceInfo&lt;/class&gt; &lt;class&gt;org.drools.persistence.processinstance.WorkItemInfo&lt;/class&gt; &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt; &lt;properties&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /&gt; &lt;property name="hibernate.connection.autocommit" value="false" /&gt; &lt;property name="hibernate.max_fetch_depth" value="3" /&gt; &lt;property name="hibernate.jndi.class" value="bitronix.tm.jndi.BitronixInitialContextFactory"/&gt; &lt;property name="hibernate.show_sql" value="true" /&gt; &lt;property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <p>In applicationContext.xml of spring I added:</p> <pre><code>&lt;bean id="dataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close"&gt; &lt;property name="className" value="oracle.jdbc.xa.client.OracleXADataSource" /&gt; &lt;property name="uniqueName" value="jdbc/testDS1" /&gt; &lt;property name="minPoolSize" value="1" /&gt; &lt;property name="maxPoolSize" value="5" /&gt; &lt;property name="driverProperties"&gt; &lt;props&gt; &lt;prop key="URL"&gt;myURL&lt;/prop&gt; &lt;prop key="user"&gt;username&lt;/prop&gt; &lt;prop key="password"&gt;password&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager"&gt; &lt;property name="transactionManager" ref="bitronixTransactionManager"/&gt; &lt;property name="userTransaction" ref="bitronixTransactionManager"/&gt; &lt;/bean&gt; &lt;bean id="bitronixTransactionManager" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices" depends-on="dataSource,txManager" destroy-method="shutdown"/&gt; </code></pre> <p>However, when I run:</p> <pre><code>EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.drools.persistence.jpa"); </code></pre> <p>I get an exception:</p> <pre><code>Caused by: org.hibernate.HibernateException: Could not find datasource: jdbc/testDS1 </code></pre> <p>The exception is on <code>ds = (DataSource ) NamingHelper.getInitialContext(props).lookup(jndiName);</code> of Hibernate infra file.</p> <ol> <li><p>What could be the problem?</p></li> <li><p>How does Hibernate persistence knows to refer to spring <code>txManager</code> bean?</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload