*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ResourceLocal to JTA" Watch "ResourceLocal to JTA" New topic
Author

ResourceLocal to JTA

baxhuli pema
Greenhorn

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
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

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


http://docs.oracle.com/javaee/5/tutorial/doc/bnbqw.html
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

The example of persistence.xml:



SCJP6, SCWCD5, OCE:EJBD6.
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
 
Similar Threads
How do I setRollBackOnly on a sessionBean using CMT and JTA
Entity not persisting
Entity Managers - Types
Persitence confusion. Please help.
EJB3 UNIT - Class cast exception