Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsEclipselink JTA without jndi
https://www.eclipse.org/forums/index.php/mv/msg/125082/383020/#msg_383020
datasource? We are currently using hibernate which allows this easily but
would like to switch to eclipselink]]>Daniel2008-11-13T19:47:33-00:00Re: Eclipselink JTA without jndi
https://www.eclipse.org/forums/index.php/mv/msg/125082/383022/#msg_383022
continuing to set the userExternalController flag.
In JPA specify the PU type to be JTA but provide a non transactional
datasource under jta-datasource tag. Or skip the datasources entirely and
just provide direct connection information.
--Gordon]]>Gordon Yorke2008-11-14T14:03:15-00:00Re: Eclipselink JTA without jndi
https://www.eclipse.org/forums/index.php/mv/msg/125082/383024/#msg_383024
How do I set the userExternalController flag? I don't see this property
anywhere. To clarify, I am using an XA datasource and spring's transaction
manager instead of a container managed transaction manager. The error I
was getting was that jtaDataSource was not being set.]]>Daniel2008-11-14T14:44:23-00:00Re: Eclipselink JTA without jndi
https://www.eclipse.org/forums/index.php/mv/msg/125082/383026/#msg_383026
you should not have to do anything special. If you are using JPA then
just set the XA datasource as your jta-datasource in the persistence.xml
file.
Can you provide details on the exception that you saw. What are the
details on your system's architecture and configuration.
--Gordon]]>Gordon Yorke2008-11-14T16:27:01-00:00Re: Eclipselink JTA without jndi
https://www.eclipse.org/forums/index.php/mv/msg/125082/383042/#msg_383042
org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
Exception Description: PersistenceUnitInfo PU has transactionType JTA, but
doesnt have jtaDataSource.
We are using JPA and are using spring's
LocalContainerEntityManagerFactoryBean.
Here is an example that works with hibernate:
<bean id="entityManagerFactory"
class=" org.springframework.orm.jpa.LocalContainerEntityManagerFacto ryBean ">
<property name="jpaVendorAdapter">
<bean class="${jpa.adapter}">
<property name="databasePlatform"
value="${jpa.platform}" />
<property name="showSql" value="${jpa.showSql}" />
<property name="generateDdl" value="${jpa.generateDdl}" />
</bean>
</property>
<property name="persistenceXmlLocation"
value="classpath:META-INF/my-persistence.xml" />
<property name="dataSource" ref="myDataSource" />
<property name="jpaPropertyMap" ref="jpaConfig" />
</bean>
and here is a sample persistence xml:
> Are you using JPA? If you are using the non JPA Spring integration then
> you should not have to do anything special. If you are using JPA then
> just set the XA datasource as your jta-datasource in the persistence.xml
> file.
> Can you provide details on the exception that you saw. What are the
> details on your system's architecture and configuration.
> --Gordon]]>Daniel2008-11-18T21:53:38-00:00Re: Eclipselink JTA without jndi
https://www.eclipse.org/forums/index.php/mv/msg/125082/387105/#msg_387105
Spring?)
Could you point me some example files/projects ?
Thanks!
Daniel wrote:
> The exception is
>
> org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
> Exception Description: PersistenceUnitInfo PU has transactionType JTA,
> but
> doesnt have jtaDataSource.
>
> We are using JPA and are using spring's
> LocalContainerEntityManagerFactoryBean.
> Here is an example that works with hibernate:
> <bean id="entityManagerFactory"
>
> class=" org.springframework.orm.jpa.LocalContainerEntityManagerFacto ryBean ">
>
> <property name="jpaVendorAdapter">
> <bean class="${jpa.adapter}">
> <property name="databasePlatform"
> value="${jpa.platform}" />
> <property name="showSql" value="${jpa.showSql}" />
> <property name="generateDdl"
> value="${jpa.generateDdl}" />
> </bean>
> </property>
> <property name="persistenceXmlLocation"
> value="classpath:META-INF/my-persistence.xml" />
> <property name="dataSource" ref="myDataSource" />
> <property name="jpaPropertyMap" ref="jpaConfig" />
> </bean>
> and here is a sample persistence xml:
>
> <persistence version="1.0"
> xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
> <persistence-unit name="PU" transaction-type="JTA">
> <class>com.foo.MyEntity</class>
> </persistence-unit>
> </persistence>
> The spring integration works with eclipselink when using non jta
> transaction type. We are using a spring datasource and not jndi.
>
> Gordon Yorke wrote:
>
>> Are you using JPA? If you are using the non JPA Spring integration
>> then you should not have to do anything special. If you are using
>> JPA then just set the XA datasource as your jta-datasource in the
>> persistence.xml file.
>
>> Can you provide details on the exception that you saw. What are the
>> details on your system's architecture and configuration.
>> --Gordon
>
>]]>Andre Ribeiro2009-04-16T14:26:49-00:00Re: Eclipselink JTA without jndi
https://www.eclipse.org/forums/index.php/mv/msg/125082/387108/#msg_387108
org.eclipse.persistence.transaction.JTATransactionController
and returning the spring jta manager
package org.foo;
public class MyJtaTransactionController extends JTATransactionController {
private static TransactionManager tm;
This class is used by eclipselink if you define the property:
eclipselink.target-server=org.foo.MyJtaTransactionController
In your spring config you can inject the transaction manager into the
static fields
<bean
class=" org.springframework.beans.factory.config.MethodInvokingFacto ryBean ">
<property name="targetClass" value="org.foo.MyJtaTransactionController"/>
<property name="targetMethod" value="setTm"/>
<property name="arguments">
<list>
<ref bean="MyTxMgr"/>
</list>
</property>
</bean>
You might also need to set a post processor to set the datasource correctly
public class MyPersistenceUnitPostProcessor implements
PersistenceUnitPostProcessor {
private DataSource jtaDataSource;
public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo
mutablePersistenceUnitInfo) {
mutablePersistenceUnitInfo.setJtaDataSource(getJtaDataSource ());
}
public DataSource getJtaDataSource() {
return jtaDataSource;
}
public void setJtaDataSource(DataSource jtaDataSource) {
this.jtaDataSource = jtaDataSource;
}
}