[rules-users] Problem with JPA session persistence in Drools Flow (5.0.1)

DroolsUser rafiuddin.mk at gmail.com
Tue Jul 28 07:41:23 EDT 2009


Mark / salaboy,


I am also facing same problem while recreate the session from database. Can
you advice any alternative, so that I can go forward till the next release. 

Moreover when is the new release is .......
Do new release will targeting this kind problem?

Please suggest any alternative to recreate the session from db.

Thanks in advance......


gairey wrote:
> 
> Mark,
> 
> Done: https://jira.jboss.org/jira/browse/JBRULES-2199 - thanks for the 
> quick response.
> 
> Regards,
> 
> Alan
> 
> 
> 
> 
> Mark Proctor  
> Sent by:
> rules-users-bounces at lists.jboss.org
> 08/07/2009 13:49
> Please respond to
> Rules Users List 
> 
> 
> To
> Rules Users List 
> cc
> 
> Subject
> Re: [rules-users] Problem with JPA session persistence in Drools Flow 
> (5.0.1)
> 
> 
> 
> 
> 
> 
> Can you open a JIRA for this, and we'll make sure it's done in the next 
> few weeks:
> https://jira.jboss.org/jira/browse/JBRULES
> 
> thanks
> 
> Mark
> 
> Alan.Gairey at tessella.com wrote: 
> 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 if a process only executes part way through, and I then 
> try to finish the process by recreating a session using the code: 
> 
> // recreate the session from database using the sessionId
> ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( sessionId, 
> kbase, null, env ); 
> 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 is called as part of the loading of a 
> knowledge session from the H2 database; this in turn leads to the 
> afterCompletion method of the inner class SynchronizationImpl being 
> called. The final two lines of this method are: 
> 
> ((JPAProcessInstanceManager) ((ReteooWorkingMemory) 
> session).getProcessInstanceManager()).clearProcessInstances(); 
> ((JPAWorkItemManager) ((ReteooWorkingMemory) 
> session).getWorkItemManager()).clearWorkItems(); 
> 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 the 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: 
> 
> if (session != null) { 
>     ((JPAProcessInstanceManager) ((ReteooWorkingMemory) 
> session).getProcessInstanceManager()).clearProcessInstances(); 
>     ((JPAWorkItemManager) ((ReteooWorkingMemory) 
> session).getWorkItemManager()).clearWorkItems(); 
> } 
> 
> 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: 
> 
> ((ReteooStatefulSession) this.session).setId( this.sessionInfo.getId() ); 
> (This line is present at the end of the 3rd constructor.) 
> It would be great if this fix could make it into the Drools 5.1 release. 
> Thanks.
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>  
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-JPA-session-persistence-in-Drools-Flow-%285.0.1%29-tp24377236p24697639.html
Sent from the drools - user mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090728/a2329596/attachment.html 


More information about the rules-users mailing list