Question

I have a stateless bean resposible for persisting entities to a database. This stateless bean is called by a message bean's onMessage method. The wired thing is that on the first message everything works fine, but on the next message the method responsible for persisting is invoked outside a transaction, even though the method is annotated with REQUIRES_NEW.

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public StateChange persistChange(long deviceId, ...) {


    ...

    StateChange change = new StateChange(...);
    em.persist(change);
    em.refresh(change); // To provoke the error

    return change;
}

Calling refresh triggers the following exception:

Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress

Any ideas? I'm fairly new to JTA so I might have missed something important?

Was it helpful?

Solution

I tried a lot to solve it and after about 16 hours or so it seems to be working. I'm not sure exactly what did the trick, but it might be the upgrade to Glassfish 2.1.

Finally able to sleep at night again!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top