How to prevent "Local transaction already has 1 non-XA Resource" exception?

Posted by Zeratul on Stack Overflow See other posts from Stack Overflow or by Zeratul
Published on 2010-04-21T22:56:50Z Indexed on 2010/04/21 23:03 UTC
Read the original article Hit count: 359

Filed under:
|
|
|
|

Hi, I'm using 2 PU in stateless EJB and each of them is invoked on one method:

@PersistenceContext(unitName="PU")
private EntityManager em;
@PersistenceContext(unitName="PU2")
private EntityManager em2;

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW )
public void getCandidates(final Integer eventId) throws ControllerException {
    ElectionEvent electionEvent = em.find(ElectionEvent.class, eventId);
    ...
    Person person = getPerson(candidate.getLogin());
    ...
}

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW )
private Person getPerson(String login) throws ControllerException {
    Person person = em2.find(Person.class, login);
    return person;
}

Those methods are annotated with REQUIRES_NEW transcaction to avoid this exception. When I was calling these method from javaFX applet, all worked as expected. Now I'm trying to call them from JAX-RS webservice (I don't see any logical difference as in both cases ejb was looked up in initial context) and I keep getting this exception. When I set up XADatasource in glassfish 2.1 connection pools, I got nullpointer exception on em2.

Any ideas what to try next?

Regards

© Stack Overflow or respective owner

Related posts about java

Related posts about ejb