2 Replies Latest reply on Dec 2, 2012 9:15 PM by Wooi Joe Chuah

    ClassCastException in DynamicUtils when using JPAKnowledgeService.loadStatefulKnowledgeSession()

    Wooi Joe Chuah Newbie

      Hi,

       

      I've encountered the problem as stated above when using DynamicUtils to addDynamicSubProcess at the following line

       

      ProcessEventSupport eventSupport = ((InternalProcessRuntime)((InternalKnowledgeRuntime)ksession).getProcessRuntime()).getProcessEventSupport();

       

      The reason as far as I know is because the ksession returned from JPAKnowledgeService.loadStatefulKnowledgeSession() or newStatefulKnowledgeSession()

      which is implemented using org.drools.persistence.jpa.KnowledgeStoreServiceImpl

      returns the ksession as a CommandBasedStatefulKnowledgeSession object instance.

       

      The CommandBasedStatefulKnowledgeSession does not implement InternalKnowledgeRuntime and hence we hit a class cast exception.

       

      The same problem does not occur when using a ksession from the KnowledgeBuilder>KnowledgeBase>ksession.

       

      Any idea if CommandBasedStatefulKnowledgeSession is going to implement InternalKnowledgeRuntime in the future or

      there's gonna be a fix for using sessions which are loaded from DB? or is it a limitation

       

      Thanks.