JBoss Community

Re: Session and thread safety

created by Gábor Farkas in jBPM - View the full discussion

The same problem here, still exists in JBpm5, 5.3.0.Final

The problem is that SingleSessionCommandService calls beginCommandScopedEntityManager on the PersistenceContextManager, but the endCommandScopedEntityManager in called when the transaction commits. When used in an EE environment, the JTA transaction commits well after the SingleSessionCommandService exits the synchronized block.

If another requests comes, and the execution enter the critical section, the CMD_SCOPED_ENTITY_MANAGER is still stored in the environment, so the new request will just use the EntityManager from the previous request, which clearly causes serious problems.

I think that this should be reportes as a bug in Jbpm5, because this prevents the correct usage of JBpm in an enterprise container. What do you think?

In my workaround, I created a CDI interceptor that synchronizes methods that use KnowledgeSession on a higher level.

Reply to this message by going to Community

Start a new discussion in jBPM at Community