Bug 724796 (BRMS-636)

Summary: Drools: Unable to load session snapshot
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Alessandro Lazarotti <alazarot>
Component: BRE (Expert, Fusion)Assignee: Mark Proctor <mproctor>
Status: VERIFIED --- QA Contact: Tomas Schlosser <tschloss>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.1.0 GACC: atangrin, etirelli, lpetrovi, mproctor, rwagner, rzhang, tschloss, tsurdilo
Target Milestone: ---   
Target Release: BRMS 5.2.0.GA   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/BRMS-636
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
BRMS 5.1
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 727547    
Bug Blocks: 740499    
Attachments:
Description Flags
TestCase.java
none
VoteCreatedEvent.java
none
New test case none

Description Alessandro Lazarotti 2011-07-12 20:43:07 UTC
Help Desk Ticket Reference: https://c.na7.visual.force.com/apex/Case_View?id=500A0000004U2csIAC&sfdc.override=1
securitylevel_name: Public

After an event is processed the session fails to load using JPA persistence.

I ve attached a test case.
It uses a Drools flow file, and a drl file. Both very simple..
The flow file has a "Start" then an action that prints a message to the console, then "End"

The Drl has one rule that processes an event:

import com.kgcontrols.services.company.standardsRequests.workflow.events.VoteCreatedEvent

declare VoteCreatedEvent
       @role(event)
end

rule "testEvents"
       when
               VoteCreatedEvent() from entry-point "VoteCreatedStream"

       then
               System.out.println("--------------------------- YEAH the event got here");
end

I can see the "YEAH the event go here" on the console so I know the rule fired. But after that, if I try to load the session from the database I get:

                                                                       
                                                                     
                                                                     
                                             
--------------------------- YEAH the event got here
ERROR 2010-09-02 10:09:26 Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
        at org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildComman
Service(KnowledgeStoreServiceImpl.java:106)
        at org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.loadStatefu
lKnowledgeSession(KnowledgeStoreServiceImpl.java:74)
        at org.drools.persistence.jpa.JPAKnowledgeService.loadStatefulKnowledgeS
ession(JPAKnowledgeService.java:118)
        at com.kgcontrols.services.company.standardsRequests.workflow.TestCase.
loadSession(TestCase.java:136)
        at com.kgcontrols.services.company.standardsRequests.workflow.TestCase.
start(TestCase.java:64)
        at org.apache.jsp.company.standardsRequest.test2_jsp._jspService(org.ap
ache.jsp.company.standardsRequest.test2_jsp:51)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:332)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at com.troux.servercommon.usagelog.UsageLogFilter.doFilter(UsageLogFilte
r.java:149)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:524)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommon
AccessLogValve.java:495)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)

        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.ja
va:684)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSock
et.java:876)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildComman
Service(KnowledgeStoreServiceImpl.java:91)
        ... 31 more
Caused by: java.lang.RuntimeException: Unable to load session snapshot
        at org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapsh
ot(JPASessionMarshallingHelper.java:96)
        at org.drools.persistence.session.SingleSessionCommandService.initKsessi
on(SingleSessionCommandService.java:196)
        at org.drools.persistence.session.SingleSessionCommandService.<init>(Sin
gleSessionCommandService.java:159)
        ... 36 more
Caused by: java.lang.NullPointerException
        at org.drools.reteoo.LeftTuple.<init>(LeftTuple.java:135)
        at org.drools.reteoo.LeftTuple.<init>(LeftTuple.java:121)
        at org.drools.marshalling.impl.InputMarshaller.readLeftTuple(InputMarsha
ller.java:461)
        at org.drools.marshalling.impl.InputMarshaller.readFactHandles(InputMars
haller.java:351)
        at org.drools.marshalling.impl.InputMarshaller.readSession(InputMarshall
er.java:205)
        at org.drools.marshalling.impl.DefaultMarshaller.unmarshall(DefaultMarsh
aller.java:91)
        at org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapsh
ot(JPASessionMarshallingHelper.java:91)
        ... 38 more
ERROR 2010-09-02 10:09:26 [EXCEPTION]
org.apache.jasper.JasperException: java.lang.reflect.InvocationTargetException
        at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspSer
vletWrapper.java:510)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:387)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at com.troux.servercommon.usagelog.UsageLogFilter.doFilter(UsageLogFilte
r.java:149)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:524)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommon
AccessLogValve.java:495)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)

        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.ja
va:684)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSock
et.java:876)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
        at java.lang.Thread.run(Thread.java:619)

Comment 1 Alessandro Lazarotti 2011-07-12 20:43:07 UTC
Link: Added: This issue Cloned from JBRULES-3037


Comment 2 Alessandro Lazarotti 2011-07-12 20:54:40 UTC
Help Desk Ticket Reference: Added: https://c.na7.visual.force.com/apex/Case_View?id=500A0000004U2csIAC&sfdc.override=1


Comment 4 Mark Proctor 2011-08-16 16:10:24 UTC
Mark is currently working on making ALL timers marshallable - at the moment only jBPM interval timers will marshall.

Once Mark commits this work (this thu/fri) edson can the check any remaining issues for this task. Fixed mid/end of next week.

Comment 5 Mark Proctor 2011-08-16 16:18:51 UTC
None of hte TimerService entries are currently marhsalled. jBPM has it's own framework for this, but only does jBPM interval timers. We need to refactor evertyhing to a single framework.

https://issues.jboss.org/browse/JBRULES-3146

Comment 6 Tihomir Surdilovic 2011-08-17 17:23:07 UTC
*** Bug 727547 has been marked as a duplicate of this bug. ***

Comment 7 lcarlon 2011-09-15 04:19:06 UTC
I've removed the technical_note flag after reviewing the Helpdesk ticket. As CEP will be supported for the first time in 5.2 no release note will be added.

Comment 8 Ryan Zhang 2011-09-19 05:24:20 UTC
The fix has been picked for next release, so I modified the state into Modified.

Comment 9 Mark Proctor 2011-09-19 07:31:26 UTC
On further investigation this is not a dupliate of Bug727547.

And instead is it's own bug, which has also now been fixed and merged to 5.2.x. You can see the jira here:
https://issues.jboss.org/browse/JBRULES-3216

Comment 10 Jiri Svitak 2011-09-20 09:57:28 UTC
Bug is still present in BRMS 5.2.0 ER4.

Comment 11 Mark Proctor 2011-09-22 00:39:28 UTC
I'll need more help to recreate this test. The provided java code is not complete, it's missing DRLs etc.

I created my own test from the sample DRL in the first comment. you can see that test here:
https://github.com/droolsjbpm/drools/commit/08947672a9d5877f939a3ea2ea0a0832c7d2e6c2#diff-0

Please either update that test or provide an additional one in the same style. You should be able to separate this from JPA layer,and thus simplifying it, and use the Marshaller, like in the test above.

Comment 12 Tihomir Surdilovic 2011-09-22 00:40:31 UTC
reassigning back to QA jsvitak@redhat.com to provide a test case.

Comment 13 Tomas Schlosser 2011-09-22 07:51:48 UTC
Created attachment 524342 [details]
New test case

As by Mark Proctor's request I'm submitting a new test case - contains a few POJO classes. It uses Marshaller instead of JPA.

Comment 14 Mark Proctor 2011-09-22 08:34:01 UTC
The test itself is invalid. In rule "UpdateCloned":
		modify ( $event ) {
			setValue(new Object());
		}

Object is itself not serializable.

Comment 15 Tomas Schlosser 2011-09-22 09:12:40 UTC
I'm sorry, I see my mistake. Now the test case works and can be ignored.
However persisting Events is still impossible due to
https://bugzilla.redhat.com/show_bug.cgi?id=740499

Comment 16 Mark Proctor 2011-09-22 09:20:39 UTC
I'll need a test case to fix bug740499

Comment 17 Tihomir Surdilovic 2011-09-26 14:56:23 UTC
Assigning back to Tomas, as Mark needs a test case to reproduce.

Comment 18 Lukáš Petrovický 2011-09-27 08:03:18 UTC
QE verifies this particular issue is fixed and the rest should happen in bug 740499.