Skip to content

Commit

Permalink
When using EJBs the EM may be closed. Need to check that.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroigor committed Oct 29, 2014
1 parent 2410722 commit 075f0a7
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -97,7 +97,9 @@ public void start(StartContext startContext) throws StartException {
@Override
public void initContextForStore(IdentityContext context, IdentityStore<?> store) {
if (store instanceof JPAIdentityStore) {
if (!context.isParameterSet(JPAIdentityStore.INVOCATION_CTX_ENTITY_MANAGER)) {
EntityManager entityManager = context.getParameter(JPAIdentityStore.INVOCATION_CTX_ENTITY_MANAGER);

if (entityManager == null || !entityManager.isOpen()) {
context.setParameter(JPAIdentityStore.INVOCATION_CTX_ENTITY_MANAGER, getEntityManager(getTransactionManager().getValue()));
}
}
Expand Down Expand Up @@ -210,7 +212,7 @@ private boolean isIdentityEntity(Class<?> cls) {
private EntityManager getEntityManager(TransactionManager transactionManager) {
EntityManager entityManager = getOrCreateTransactionalEntityManager(transactionManager);

if (entityManager == null) {
if (entityManager == null || !entityManager.isOpen()) {
entityManager = createEntityManager(transactionManager);
}

Expand Down

0 comments on commit 075f0a7

Please sign in to comment.