Forums Register Login

Setting JTA with JPA

+Pie Number of slices to send: Send
Dear All,

I have a JPA java project with its [persistence.xml].
During running the project, the logger logs the following:
[WARN AbstractEntityManagerImpl:551 -Calling joinTransaction() on a non JTA EntityManager]

I am using joinTransaction() from the EntityManager class.

Would you please tell me how to set the (JTA) with the [persistence.xml] ?


Best Regards,
Ahmed Abbas
+Pie Number of slices to send: Send
In persistence.xml you should use the transaction-type element for the persistence-unit tag as below:

<persistence-unit name="Your_unit_name" transaction-type="JTA">
+Pie Number of slices to send: Send
Hello Devaka,

Many thanks for your reply, yet please I need more elaboration.

I searched for how to set the JTA properly into my [persistence.xml], yet didn't reach to a solid answer.

Do you recommend a source to read as to know how to set the [persistence.xml] properly?

How does a JTA datasource differ from non jta datasource ?
( Is this related to who will take care of transactions ? - either JTa ( managed env ) or JDBC etc ( Non Managed )

How to define a jta datasource properly ? need full example in [persistence.xml] or link? please?

Also, I am asking about the needed lib files (jars) for creating a java project (with JPA facet) under Eclipse 3.4 using JPA API with Persistence Provider (Hibernate).
I am listing the ones I have by version, and please comment on the list if any is missing or not required?

-----------------------------------------------------------------
antlr-2.7.6.jar
asm.jar
commons-collections-3.1.jar
commons-lang-2.0.jar
dom4j-1.6.1.jar
ejb3-persistence-1.0.2.GA.jar
hibernate3.jar
hibernate-annotations-3.4.0.GA.jar
hibernate-commons-annotations-3.1.0.GA.jar
hibernate-core-3.3.1.GA.jar
hibernate-entitymanager.jar
javassist-3.4.ga.jar
jta-1.1.jar
log4j-1.2.15.jar
slf4j-api-1.5.6.jar
slf4j-log4j12-1.5.6.jar
slf4j-simple-1.5.6.jar
xml-apis-1.0.b2.jar
-----------------------------------------------------------------

Again, many thanks and waiting your reply.

Best Regards,
Ahmed Abbas
+Pie Number of slices to send: Send
The type of the transaction (JTA or resource-local) should depend on the type of the data source (JTA or non-JTA), on many application servers. If a JTA datasource is used in this case, then the transaction type should be JTA. If non-jta datasource is used, then you should select to use resource-local as the transaction-type of the persistence unit. However, in some persistence providers, you can use both jta and non-jta datasource within the same persistence unit. In that case the non-jta datasource can be used where JTA is unavailable.

This is an example of using jta-data source in a persistence unit with the jta transaction type:




For the library jar files, it seems that you've listed all of the required files.

Devaka.
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 8317 times.
Similar Threads
javax.persistence. TransactionRequiredException
Application-Managed Transaction without joining
Container-Manager EntityManager - Automatically joins JTA ?
Persistence.xml | No JNDI Datasource
Using joinTransaction() on resource-local entity managers.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:43:45.