[rules-users] Hibernate

Heyns, Juan Juan.Heyns at lonplats.com
Fri Sep 28 05:01:02 EDT 2007


This is very strange. Let me explain the scenario and you can tell me if
we have something fundamentally wrong.



We have a class (Persister) that receives a lightweight object (VO) to
persist, the Persister does the following:

1.       Starts a hibernate transaction

2.       Creates hibernate pojo's and calls
session.save(persister_created_pojo) on each of the pojo's

3.       Passes these objects to Drools, which creates more hibernate
pojo's and returns them

4.       The Persister class then calls
session.save(drools_created_pojo) for each of the returned pojo's

5.       If no errors exist the transaction is committed, otherwise it
is rolled back.



When we updated the drules packages from 4.0.0 to 4.0.1 we started
getting these errors, it seems like the session gets

disconnected the moment we pass the pojo to drools.



Maybe someone has some advice or has encountered something similar.



Juan



From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Mark Proctor
Sent: 27 September 2007 04:12 PM
To: Rules Users List
Cc: juan.heyns at epiuse.com
Subject: Re: [rules-users] Hibernate



Drools doesn't handle Hibernate in anyway, we have no awareness of it.
The exceptions indicates that you have lazy loading enabled for
hibernate, but your session is disconnected when it tries to lazy load
the object.

Mark
Heyns, Juan wrote:

Hi,



I am getting the following error with 4.0.1, I didn't get this with
4.0.0... Has anything changed in the way Drools works with Hibernate.



Juan



15:24:52,281 ERROR LazyInitializationException:19 - failed to lazily
initialize a collection, no session or session was closed

org.hibernate.LazyInitializationException: failed to lazily initialize a
collection, no session or session was closed

      at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ
ationException(AbstractPersistentCollection.java:358)

      at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ
ationExceptionIfNotConnected(AbstractPersistentCollection.java:350)

      at
org.hibernate.collection.AbstractPersistentCollection.readElementExisten
ce(AbstractPersistentCollection.java:132)

      at
org.hibernate.collection.PersistentSet.contains(PersistentSet.java:153)

      at
org.drools.base.evaluators.ObjectFactory$ObjectContainsEvaluator.evaluat
eCachedLeft(ObjectFactory.java:481)

      at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestrict
ion.java:72)

      at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstrain
t.java:72)

      at
org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaCo
nstraints.java:117)

      at org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:119)

      at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTupl
e(CompositeTupleSinkAdapter.java:73)

      at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode
.java:131)

      at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleOb
jectSinkAdapter.java:20)

      at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:160)

      at org.drools.reteoo.Rete.assertObject(Rete.java:176)

      at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:196)

      at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:
70)

      at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:854)

      at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:826)

      at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:60)

      at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:54)

      at
com.lonmin.bns.domain.rules.Rule_Stope_Drilling_work_is_evaluated_based_
on_the_holes_drilled_and_blasts_0.consequence(Rule_Stope_Drilling_work_i
s_evaluated_based_on_the_holes_drilled_and_blasts_0.java:35)

      at
com.lonmin.bns.domain.rules.Rule_Stope_Drilling_work_is_evaluated_based_
on_the_holes_drilled_and_blasts_0ConsequenceInvoker.evaluate(Rule_Stope_
Drilling_work_is_evaluated_based_on_the_holes_drilled_and_blasts_0Conseq
uenceInvoker.java:22)

      at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)

      at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)

      at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:434)

      at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:396)

      at
com.lonmin.bns.domain.rules.RulesEngine.calculateStopeDrillingBonus(Rule
sEngine.java:54)

      at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.processDetail(Sto
peDrillingCardPersister.java:371)

      at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.processCard(Stope
DrillingCardPersister.java:276)

      at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.process(StopeDril
lingCardPersister.java:69)

      at
com.lonmin.bns.domain.model.ValueObjectPersister.persist(ValueObjectPers
ister.java:38)

      at
com.lonmin.bns.domain.model.StopeDrillingCardPersisterTest.testEditStope
DrillingCard(StopeDrillingCardPersisterTest.java:182)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)

      at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:324)

      at junit.framework.TestCase.runTest(TestCase.java:164)

      at junit.framework.TestCase.runBare(TestCase.java:130)

      at junit.framework.TestResult$1.protect(TestResult.java:106)

      at junit.framework.TestResult.runProtected(TestResult.java:124)

      at junit.framework.TestResult.run(TestResult.java:109)

      at junit.framework.TestCase.run(TestCase.java:120)

      at junit.framework.TestSuite.runTest(TestSuite.java:230)

      at junit.framework.TestSuite.run(TestSuite.java:225)

      at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:392)

      at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:276)

      at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:167)

org.hibernate.LazyInitializationException: failed to lazily initialize a
collection, no session or session was closed

      at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ
ationException(AbstractPersistentCollection.java:358)

      at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ
ationExceptionIfNotConnected(AbstractPersistentCollection.java:350)

      at
org.hibernate.collection.AbstractPersistentCollection.readElementExisten
ce(AbstractPersistentCollection.java:132)

      at
org.hibernate.collection.PersistentSet.contains(PersistentSet.java:153)

      at
org.drools.base.evaluators.ObjectFactory$ObjectContainsEvaluator.evaluat
eCachedLeft(ObjectFactory.java:481)

      at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestrict
ion.java:72)

      at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstrain
t.java:72)

      at
org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaCo
nstraints.java:117)

      at org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:119)

      at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTupl
e(CompositeTupleSinkAdapter.java:73)

      at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode
.java:131)

      at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleOb
jectSinkAdapter.java:20)

      at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:160)

      at org.drools.reteoo.Rete.assertObject(Rete.java:176)

      at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:196)

      at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:
70)

      at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:854)

      at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:826)

      at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:60)

      at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:54)

      at
com.lonmin.bns.domain.rules.Rule_Stope_Drilling_work_is_evaluated_based_
on_the_holes_drilled_and_blasts_0.consequence(Rule_Stope_Drilling_work_i
s_evaluated_based_on_the_holes_drilled_and_blasts_0.java:35)

      at
com.lonmin.bns.domain.rules.Rule_Stope_Drilling_work_is_evaluated_based_
on_the_holes_drilled_and_blasts_0ConsequenceInvoker.evaluate(Rule_Stope_
Drilling_work_is_evaluated_based_on_the_holes_drilled_and_blasts_0Conseq
uenceInvoker.java:22)

      at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)

      at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)

      at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:434)

      at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:396)

      at
com.lonmin.bns.domain.rules.RulesEngine.calculateStopeDrillingBonus(Rule
sEngine.java:54)

      at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.processDetail(Sto
peDrillingCardPersister.java:371)

      at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.processCard(Stope
DrillingCardPersister.java:276)

      at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.process(StopeDril
lingCardPersister.java:69)

      at
com.lonmin.bns.domain.model.ValueObjectPersister.persist(ValueObjectPers
ister.java:38)

      at
com.lonmin.bns.domain.model.StopeDrillingCardPersisterTest.testEditStope
DrillingCard(StopeDrillingCardPersisterTest.java:182)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)

      at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:324)

      at junit.framework.TestCase.runTest(TestCase.java:164)

      at junit.framework.TestCase.runBare(TestCase.java:130)

      at junit.framework.TestResult$1.protect(TestResult.java:106)

      at junit.framework.TestResult.runProtected(TestResult.java:124)

      at junit.framework.TestResult.run(TestResult.java:109)

      at junit.framework.TestCase.run(TestCase.java:120)

      at junit.framework.TestSuite.runTest(TestSuite.java:230)

      at junit.framework.TestSuite.run(TestSuite.java:225)

      at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:392)

      at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:276)

      at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:167)



"Employees of Lonmin Platinum ("Lonplats") are not authorised to
conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee
shall
not be legally binding on Lonplats and Lonplats shall incur no liability
of
any nature whatsoever, directly or indirectly, arising from such act on
the
part of it's employee. It is further recorded that nothing (other than
an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"




________________________________




_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
 





"Employees of Lonmin Platinum ("Lonplats") are not authorised to conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee shall
not be legally binding on Lonplats and Lonplats shall incur no liability of
any nature whatsoever, directly or indirectly, arising from such act on the
part of it's employee. It is further recorded that nothing (other than an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070928/2a0a2007/attachment.html 


More information about the rules-users mailing list