wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes ResourceLocal to JTA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ResourceLocal to JTA" Watch "ResourceLocal to JTA" New topic

ResourceLocal to JTA

baxhuli pema

Joined: Nov 09, 2012
Posts: 11
I am developing an web application and I have to use JTA which I never used. I started using EntityManager but it seems not to work here. When I use EntityManager I get this message:

To cut it short, I have this piece of code:

How can I do this without EntityManager?
James Boswell

Joined: Nov 09, 2011
Posts: 1030

I assume you have a persistence.xml file on your classpath? This is where you define the transaction type.

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804

The example of persistence.xml:

BLOG: http://leakfromjavaheap.blogspot.com
Mahendr Shinde
Ranch Hand

Joined: Sep 03, 2011
Posts: 38

Hi baxhuli ,
Are you trying JPA inside a simple web application? In case you are trying to run it web application or java project, you must be using "Resource_local". Which means @PersistenceContext annotation might not work!
An EJB Application provides JTA resource and annotation to inject EntityManager.

There is still lot to learn!
It is sorta covered in the JavaRanch Style Guide.
subject: ResourceLocal to JTA