Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes Setting JTA with JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Setting JTA with JPA" Watch "Setting JTA with JPA" New topic
Author

Setting JTA with JPA

Ahmed Abbas
Greenhorn

Joined: Feb 27, 2008
Posts: 4
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


Best Regards,
Ahmed M. Abbas
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3013
    
  35

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">


Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
Ahmed Abbas
Greenhorn

Joined: Feb 27, 2008
Posts: 4
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
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3013
    
  35

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting JTA with JPA
 
Similar Threads
Application-Managed Transaction without joining
Persistence.xml | No JNDI Datasource
Using joinTransaction() on resource-local entity managers.
Container-Manager EntityManager - Automatically joins JTA ?
javax.persistence. TransactionRequiredException