Catch 22 with JBAS011437
tony.herstell1 Jan 8, 2013 4:13 PMI get this error:
JBAS011437: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it. This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context. See JPA spec 2.0 section 7.6.3.1. Scoped persistence unit name=xxxx.war#xxxDatasource, persistence context already in transaction =org.hibernate.ejb.EntityManagerImpl@1218f921, extended persistence context =ExtendedEntityManager [xxx.war#apiarymanagerDatasource].
I have a conversational bean
// Leverage EJB to get Transactional Support @Stateful // Lets be long running (multiple client-server round trips) - Needs Extended on // PersistanceContext too to hold onto my objects and not get LIEs. @ConversationScoped // EL Can can find me... @Named public class OrganisationManagementController extends BaseController { ... // Access to the persistence store so we can read from the DB with Long // Running extension to go with Conversation Scope above. @PersistenceContext(type = PersistenceContextType.EXTENDED) private EntityManager em; ...
I have to used PersistenceContextType.EXTENDED to stop getting LIEs (Lazy...).
In the rountine (inside the running conversation):
public String createOrganisation(Organisation organisation) { this.logger.info(">>>createOrganisation");
I need to grab something so do a query to get it...
List<OrganisationRole> listWithAdministratorRoleForAdmin = this.em.createQuery("select role from organisationRole role where role.organisationRoleKind = :role").setParameter("role", OrganisationRoleKind.ADMINISTRATOR) .getResultList();
This gives the exception....
Since:
1. I cannot stop using PersistenceContextType.EXTENDED as its Conversational (see above)
2. Its Transactional @Stateful
please can you suggest a solution.
This is also very odd as I didn't get it yesterday at COP (the only changes yesterday were to rip out all JEE Events logic as found it was the root cause of some very strange errors).