dev@glassfish.java.net

Re: PU with TX Type JTA

From: Arun Gupta <Arun.Gupta_at_Sun.COM>
Date: Fri, 15 Jun 2007 17:11:29 -0700

Ok, I figured out how to set the transaction type (manually edit
persistence.xml). But now I'm getting:

-- cut here --
Exception Description: Cannot use an EntityTransaction while using JTA.
         at
oracle.toplink.essentials.internal.ejb.cmp3.transaction.JTATransactionWrapper.getTransaction(JTATransactionWrapper.java:66)
         at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.getTransaction(EntityManagerImpl.java:340)
         at
com.sun.enterprise.util.EntityManagerWrapper.getTransaction(EntityManagerWrapper.java:1094)
-- cut here --

Here is my code for a WebApplication:
-- cut here --
  @PersistenceContext(unitName="JavaLibrary1PU")
     EntityManager em;
em.getTransaction();
         Company c = new Company("1", "AAA Co", (float)10.0, (float)2.0,
(float)10.0, "Jun 15, 2007");
         em.persist(c);
         out.println("Persisting to the source ...");
         em.getTransaction().commit();
         out.println("and now committed!");
-- cut here --

What is missing ?

-Arun

Arun Gupta wrote:
> Here is a great error message I see when deploying an error:
>
> -- cut here --
> Deploying application in domain failed; Deployment Error -- The
> persistence-context-ref-name [sample.NewServlet/em] in module
> [C:\Users\Arun Gupta\WebApplication5\build\web] resolves to a
> persistence unit called [JavaLibrary1PU] which is of type
> RESOURCE_LOCAL. Only persistence units with transaction type JTA can be
> used as a container managed entity manager. Please verify your application.
> -- cut here --
>
> Little detailed but very clearly conveys what is possibly wrong in the
> application. Now how do I fix it when generating this PU in NB ?
>
> -Arun

-- 
Technology Evangelist
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta