JBoss Community

Re: Null cmdScopedEntityManager during stateful session load

created by Bira Neto in jBPM - View the full discussion

Unfortunately, not passing the transaction is not a good option for me as I don't want to use and have to setup jndi on a specific server (I want to abstract this issues)

 

What solved for me was to bypass the current JpaProcessPersistenceContextManager implementation  (which may still have a bug... I would make some tests).

 

I changed my environment initialization to

 

  env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                    env.set(EnvironmentName.TRANSACTION, ut);

 

                    env.set(EnvironmentName.TRANSACTION_MANAGER, new JtaTransactionManager( ut,

                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),

                TransactionManagerServices.getTransactionManager() ));

                    env.set(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, new JPAProcessPersistenceContextManagerPk(env));

 

 

On my JPAProcessPersistenceContextManagerPk (extends JpaProcessPersistenceContextManager) I overrided the current getProcessPersistenceContext to the implementation below

 

    public ProcessPersistenceContext getProcessPersistenceContext() {

                   if (cmdScopedEntityManager == null) {

                                  this.beginCommandScopedEntityManager();

                   }

        return new JpaProcessPersistenceContext( cmdScopedEntityManager );

    }

Reply to this message by going to Community

Start a new discussion in jBPM at Community