[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2199) NullPointerException with JPA session persistence in Drools Flow

Shital Mehta (JIRA) jira-events at lists.jboss.org
Fri Jul 24 08:10:29 EDT 2009


    [ https://jira.jboss.org/jira/browse/JBRULES-2199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12477436#action_12477436 ] 

Shital Mehta commented on JBRULES-2199:
---------------------------------------

Guys,

I hit the same problem. It seems persistence (or may be drools flow itself) is not a yet a widely used feature. I was just about to recommend drools in my company over jBPM 4.0 as I thought rules+workflow is a very powerful combination but will have to wait till drools seriously starts supporting long living workflow sessions.

> NullPointerException with JPA session persistence in Drools Flow
> ----------------------------------------------------------------
>
>                 Key: JBRULES-2199
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-2199
>             Project: JBoss Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core (flow)
>    Affects Versions: 5.0.1.FINAL
>            Reporter: Alan Gairey
>            Assignee: Mark Proctor
>
> I'm currently using Drools Flow with JPA session persistence enabled as described in section 5.1 of the User Guide.
> As a process executes, session information is saved to the H2 database correctly.
> The problem comes when recreating a session from its persisted state, using the code:
> {code}
> // recreate the session from database using the sessionId
> ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( sessionId, kbase, null, env );
> {code}
> This gives me a NullPointerException.
> Having looked into the Drools Flow source code, I think the problem is in the class drools-persistence-jpa\src\main\java\org\drools\persistence\session\SingleSessionCommandService.java.
> The 4th constructor of this class (starting line 132) is called as part of the loading of a knowledge session from the H2 database (i.e. via the code above); this in turn leads to the afterCompletion method of the inner class SynchronizationImpl being called. The final two lines of this method are:
> {code}
> ((JPAProcessInstanceManager) ((ReteooWorkingMemory) session).getProcessInstanceManager()).clearProcessInstances();
> ((JPAWorkItemManager) ((ReteooWorkingMemory) session).getWorkItemManager()).clearWorkItems();
> {code}
> However, when called via the route described above, the session member variable of SingleSessionCommandService has not been set, thus causing the NullPointerException.
> (Interestingly, running the unit tests for drools-persistence-jpa does result in a NullPointerException being thrown multiple times, although the tests are still listed as having passed.)
> I believe enclosing the above two lines as follows will fix the problem:
> {code}
> if (session != null) { 
>     ((JPAProcessInstanceManager) ((ReteooWorkingMemory) session).getProcessInstanceManager()).clearProcessInstances(); 
>     ((JPAWorkItemManager) ((ReteooWorkingMemory) session).getWorkItemManager()).clearWorkItems(); 
> } 
> {code}
> Also, in the 4th constructor of SingleSessionCommandService, after the session has been set, the following line needs to be added to ensure the session id is the same as the session info id:
> {code}
> ((ReteooStatefulSession) this.session).setId( this.sessionInfo.getId() );
> {code}
> (This line _is_ present at the end of the 3rd constructor - line 123.)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list