[rules-users] Two Integration Servers sharing a single persisted session?

dunnlow dunnlow at yahoo.com
Tue Mar 11 19:40:04 EDT 2014


I'm using Drools 5.5 with Hibernate 4 and Spring 3.1.

I am trying to implement the shared persisted session referenced
(http://www.plugtree.com/making-a-non-persistent-ha-knowledge-session/) but
I can not get it to work.  I have two knowledge sessions (two instances of
the drools integration server) and I would like to share the same persisted
session (they both call JPAKnowledgeService.loadStatefulKnowledgeSession()
on the same session id).

The two integration servers (running in Tomcat) are of course deployed
(started) one after the other.  They both successfully start and load the
existing knowledge session from the database
(JPAKnowledgeServer.loadStatefulKnowledgeSession)  both instances print out
the objects that were stored in the persisted knowledge session.

The session that is started last continues to work fine, but the other
server throws the vague exception below with no other messages when I send a
command to it.  If I restart the one that isn't working, that one comes up
and starts working and the other instance returns an Exception from then on.

Same basic issue when I create a new session
(JPAKnowledgeServer.newStatefulKnowledgeSession()).

With TRACE debugging, the only exception I am getting in the server logs is:
      *org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
      WARNING: WebApplicationException has been caught : Could not commit
session or rollback*

With debug I see that Hibernate is identifying the dirty session, updating
optlock and trying to update the session (see below) but then rolling back
(I am not sure why the upodate to session is rolling back, but nothing in
the logs indicates the rollback even failed).  I'm using local transactions
(transaction-type="RESOURCE_LOCAL").

I've tried configuring both
org.springframework.orm.hibernate4.HibernateTransactionManager as well as
org.springframework.orm.jpa.JpaTransactionManager (via spring XML config)
but get the same error with both.

First, is it correct that this /SHOULD/  be possible to do?

Secondly, before I post my full spring/hibernate configuration, does anyone
have any thoughts about what is causing this or ways to troubleshoot?

Thanks in advance for any thoughts,
-J

a summary of the rollback trace:
org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.enlistInCurrentTransaction(423)
- Starting resource local transaction on application-managed EntityManager
[org.hibernate.ejb.EntityManagerImpl at cas5ed94]
.
.
org.hibernate.SQL.logStatement(104) - update SessionInfo set
lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=?
and OPTLOCK=?
org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(1137) - Mark
transaction for rollback
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.rollback(203) -
rolling back
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doRollback(164)
- rolled JDBC Connection
.
.
.



--
View this message in context: http://drools.46999.n3.nabble.com/Two-Integration-Servers-sharing-a-single-persisted-session-tp4028651.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list