users@glassfish.java.net

Re: Using _at_Transactional

From: Arun Gupta <arun.p.gupta_at_oracle.com>
Date: Mon, 6 May 2013 15:20:44 -0700 (PDT)

Hi Steven,

This is a known issue and filed a bug for tracking:

https://java.net/jira/browse/GLASSFISH-20480

Everything works after falling back on 84.

Arun

On 5/5/13 1:56 PM, Steven Van Impe wrote:
> I'm trying to rework some of my JAX-RS projects to use CDI instead of EJB. I started by trying out this little example (using a JPA entity class Message):
>
> @Path("test")
> @RequestScoped
> public class TestService {
>
> @PersistenceContext
> private EntityManager em;
>
> @Transactional
> @GET
> @Produces(MediaType.TEXT_PLAIN)
> public Message test() {
> return em.find(Message.class, 1);
> }
> }
>
> This deploys fine (using GlassFish 4 b87), but when I try a GET request, I get the following exception:
>
> javax.transaction.TransactionRequiredException: Managed bean with Transactional annotation and TxType of MANDATORY called outside of a transaction context
>
> I've tried changing @Transactional to @Transactional(Transactional.TxType.REQUIRED) -even though REQUIRED should be the default according to the JTA 1.2 JavaDoc- as well as annotating the class instead of the method, but I always get the same exception. Am I missing something here? I tried something similar to this during the Java EE 7 Hand-on Lab @ Devoxx UK, and it seemed to work fine then (using an older build of GlassFish).

-- 
http://twitter.com/arungupta
http://blogs.oracle.com/arungupta