[jboss-user] [jBPM] - Re: Session and thread safety

Michał Mański do-not-reply at jboss.com
Sat Sep 29 14:58:37 EDT 2012


Michał Mański [https://community.jboss.org/people/mmanski] created the discussion

"Re: Session and thread safety"

To view the discussion, visit: https://community.jboss.org/message/762354#762354

--------------------------------------------------------------
Hi,
I use JBPM 5.3.0.Final in my project. My application uses EJB 3.1/JPA 2.0 and runs on JBoss 7.1.1.Final. I have similar problem with thread safety.
When I use one session for whole application, strange exceptions are thrown (e.g. "javax.persistence.PersistenceException: error during managed flush ... caused by: org.hibernate.AssertionFailure: collection [null] was not processed by flush()", "javax.persistence.PersistenceException: error during managed flush ... Caused by: java.util.ConcurrentModificationException" or "org.hibernate.HibernateException: Found two representations of same collection: org.jbpm.persistence.processinstance.ProcessInstanceInfo.eventTypes") if many users use the application simultaneously. I tried to use the ProcessPersistenceContextManager presented by Sebastian, but it didn't resolve the problem - errors still appear.

When I try to user another solution and create new session for every request, I don't know how to dispose sessions. I read in documentation that this method must always be called after finishing using the session, or the engine will not free the memory used by the session. However, I don't know how to correctly dispose a session. 

If I try to dispose session before end of transaction, an exception is thrown during committing transaction: "javax.persistence.PersistenceException: error during managed flush ... Caused by: java.lang.IllegalStateException: Illegal method call. This session was previously disposed". 
On the other hand, if i dispose session after transaction commits, another exception is thrown: "Could not commit session: javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call".

Does anyone know what is the correct way to dispose a session?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/762354#762354]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120929/6170094f/attachment.html 


More information about the jboss-user mailing list