Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 965611

Summary: ClassCastException during fact insertion when two instances of a KieSession are obtained for the same KieModule
Product: [Retired] JBoss BRMS Platform 6 Reporter: Marek Winkler <mwinkler>
Component: BREAssignee: Mario Fusco <mfusco>
Status: CLOSED CURRENTRELEASE QA Contact: Marek Winkler <mwinkler>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.0CC: rzhang
Target Milestone: DR4   
Target Release: 6.0.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 20:19:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Full exception stacktrace none

Description Marek Winkler 2013-05-21 12:08:36 UTC
Created attachment 751089 [details]
Full exception stacktrace

Description of problem:

When creating two instances of the same KieSession from KieContainer instances obtained for the same ReleaseId, a CCE occurs during insertion of the facts into the second KieSession instance. 

If you swap the KieSessions used in the test, the problem arises every time in the second KieSession evaluating the rules. The problem shows up also when using KieModule defining two KieSessions for one KieBase.

When constructing the KieModule every time from scratch, the problem does not occur. The problem also does not occur when using the same instance of KieContainer for creating both KieSessions.

The ClassCastException refers to classes generated for facts defined in DRL.


Version-Release number of selected component (if applicable):

BRMS 6.0.0.DR4
Drools 6.0.0-SNAPSHOT


How reproducible:

I will attach a reference to PR with reproducer.

The test scenario is as follows:

1. create a KieModule with ReleaseId id defining one KieBase with one KieSession

2. get a KieContainer from KieServices.newKieContainer(id) and obtain a KieSession from this KieContainer; insert test facts into this session, no problem occurs

3. get another KieContainer from KieServices.newKieContainer(id) and obtain another KieSession from this KieContainer; try to insert test facts into this session, a ClassCastException occurs (see attachment for the full stacktrace):

java.lang.ClassCastException: org.drools.compiler.integrationtests.Parent cannot be cast to org.drools.compiler.integrationtests.Parent
	at ConditionEvaluator1113e873a5ac4b8a98ffd475b0b5df68.evaluate(Unknown Source)
	at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:212)
	at org.drools.core.rule.constraint.MvelConstraint.isAllowedCachedLeft(MvelConstraint.java:181)
	at org.drools.core.common.DoubleNonIndexSkipBetaConstraints.isAllowedCachedLeft(DoubleNonIndexSkipBetaConstraints.java:134)
	at org.drools.core.reteoo.JoinNode.propagateFromLeft(JoinNode.java:135)

....

Please note that Parent is a class for fact defined in DRL. The exception happens during the insert operation (NamedEntryPoint.insert).


Actual results:

Inserting facts into the second KieSession throws a CCE.


Expected results:

Inserting facts works for both KieSessions.

Comment 1 Marek Winkler 2013-05-21 12:18:30 UTC
The reproducer test case can be found at https://github.com/droolsjbpm/drools/pull/200.

Comment 2 Marek Winkler 2013-06-11 10:34:57 UTC
Verified on BRMS 6.0.0 DR5 (Drools 6.0.0.Beta3).

Comment 6 Lukáš Petrovický 2014-02-07 16:15:45 UTC
This BZ has been part of the 6.0.0 stream.