Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Setting JTA with JPA

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 6611
1253
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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">
 
Ahmed Abbas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 6611
1253
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
We're all out of roofs. But we still have tiny ads:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic