File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 1051

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: 808

The example of persistence.xml:

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!
I agree. Here's the link:
subject: ResourceLocal to JTA
It's not a secret anymore!