Bug 724415 (BRMS-360) - Generated types should be serializable
Summary: Generated types should be serializable
Keywords:
Status: CLOSED NEXTRELEASE
Alias: BRMS-360
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: 5.0.2
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
: 5.1.0 GA,5.1.0.ER1
Assignee: Tihomir Surdilovic
QA Contact:
URL: http://jira.jboss.org/jira/browse/BRM...
Whiteboard:
Depends On:
Blocks: 724416 BRMS-369
TreeView+ depends on / blocked
 
Reported: 2010-08-30 16:29 UTC by Matt Davis
Modified: 2010-11-23 12:54 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-11-23 12:54:06 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker BRMS-360 0 None None None Never

Description Matt Davis 2010-08-30 16:29:13 UTC
Help Desk Ticket Reference: https://c.na7.visual.force.com/apex/Case_View?id=500A0000003hSwh&sfdc.override=1
securitylevel_name: Public

Hello,

Recently I've been working with Drools version 5.0.1 to set up an event processor. While doing so I have come
across difficulties with the accumulate function, in that it will always throw a ClassCastException
when inserting events that are declared within my drl file. To illustrate this I've set up an example which is
shown below. I've search Google and the mailing list for several hours, but the only way past this problem
appears to be that I will have to declare a class externally and make sure it implements Serializable. Does
anyone has suggestions for another approach? Secondly, I would have assumed that since Drools was
compiling these internally declared classes, that Serializable would have been implemented automatically. So
is this a result of the generated class not implementing Serializable, or have I missed something in my rules
file? Thanks.

The important part of my drl file is:

declare TestEvent
   @role( event )
   @expires(10s)
   id : String
end

#This rule works fine when 'Accumulate Count' is commented out, and is used to make
#sure that the event inserting has worked.
rule "Is It There"
    when
        TestEvent() from entry-point "test"
    then
        System.out.println("Found a TestEvent.");
end

#This rule throws a ClassCastException when a TestEvent is inserted.
rule "Accumulate Count"
    when
        $n : Number() from accumulate($t : TestEvent() from entry-point "test", count($t))
    then
        System.out.println("Found " + $n + " events.");
end

The unit test does this:

FactType testEventType = session.getKnowledgeBase().getFactType("com.drools.test", "TestEvent");
for(int i = 0; i < 10; i++){
    Object testEvent = testEventType.newInstance();
    testEventType.set(testEvent, "id", "id");
    WorkingMemoryEntryPoint mainStream = session.getWorkingMemoryEntryPoint("test");
    mainStream.insert(event);
    session.fireAllRules();
}

The exception I receive is:

org.drools.RuntimeDroolsException: java.lang.ClassCastException: com.drools.test.TestEvent cannot be cast to java.io.Serializable
    at org.drools.rule.Accumulate.accumulate(Accumulate.java:172)
    at org.drools.reteoo.AccumulateNode.modifyTuple(AccumulateNode.java:424)
    at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:284)
    at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
    at org.drools.reteoo.PropagationQueuingNode$AssertAction.execute(PropagationQueuingNode.java:326)
    at org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:221)
    at org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:394)
    at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1486)
    at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:158)
    at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:122)
    at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:80)
    at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:28)
    at com.drools.test.MyUnitTest.testEvents(EvaluationTest.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
    at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
    at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
    at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
    at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
    at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
    at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
    at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassCastException: com.drools.test.TestEvent cannot be cast to java.io.Serializable
    at org.drools.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(JavaAccumulatorFunctionExecutor.java:110)
    at org.drools.rule.Accumulate.accumulate(Accumulate.java:164)
    ... 36 more

Comment 1 Matt Davis 2010-08-30 16:30:40 UTC
Link: Added: This issue depends JBRULES-2202


Comment 2 Matt Davis 2010-08-30 18:22:31 UTC
Link: Added: This issue is a dependency of BRMS-361


Comment 3 Tihomir Surdilovic 2010-09-08 19:11:06 UTC
Link: Added: This issue duplicates BRMS-342


Comment 4 Tihomir Surdilovic 2010-09-08 19:11:38 UTC
Duplicate of BRMS-342. Resolving and Closing. Fix avail in 5.1

Comment 5 Matt Davis 2010-09-10 20:25:41 UTC
Link: Added: This issue is a dependency of BRMS-369


Comment 6 David Le Sage 2010-10-26 00:57:01 UTC
Draft text for release notes states:

https://jira.jboss.org/browse/JBRULES-2202

ClassCastExceptions would occur if the user was utilising the accumulate function to insert 
declared events into the DRL file. This was caused by the MVELAccumulateFunctionExecutor requiring facts be serializable. This is no longer the case, so these exceptions no longer occur. 

Comment 7 Dana Mison 2010-10-26 06:55:43 UTC
Writer: Added: dlesage


Comment 8 Dana Mison 2010-10-26 07:10:29 UTC
Release Notes Docs Status: Added: Documented as Resolved Issue


Comment 9 Dana Mison 2010-10-27 03:06:31 UTC
Release Notes Text: Added: test


Comment 10 Dana Mison 2010-10-27 03:13:47 UTC
Release Notes Text: Removed: test 


Comment 11 David Le Sage 2010-11-15 06:41:51 UTC
Release Notes Text: Added: Draft text for release notes states:

https://jira.jboss.org/browse/JBRULES-2202

ClassCastExceptions would occur if the user was utilising the accumulate function to insert
declared events into the DRL file. This was caused by the MVELAccumulateFunctionExecutor requiring facts be serializable. This is no longer the case, so these exceptions no longer occur. 


Comment 12 Lukáš Petrovický 2010-11-23 12:54:05 UTC
Verified fixed in 5.1.0 ER4.


Note You need to log in before you can comment on or make changes to this bug.