users@glassfish.java.net

Cannot use an EntityTransaction while using JTA.

From: Ryan de Laplante <ryan_at_ijws.com>
Date: Tue, 27 Mar 2007 16:47:28 -0400

Hi,

I have a Java 5 web application who's only purpose is to provide a web
service. The web service uses JPA to read an entity from the database,
make a change and save it back into the db. Because this is not an EJB,
I have to manually begin and commit a transaction for persist() to work.

When I do the following, the app server throws an IllegalStateException
("Cannot use an EntityTransaction while using JTA.")

EntityTransaction trans;
trans = em.getTransaction();


I opened my persistence.xml in NetBean's visual editor, unchecked "Use
Java Transaction APIs", then saved and redeployed. This did not make a
difference. I noticed a transaction-type="JTA" attribute was still on
the <persistence-unit> element so I removed it, saved and redeployed. I
still get an exception.


Thanks,
Ryan