[jboss-jira] [JBoss JIRA] (DROOLS-3337) ClassCastException while using SessionPseudoClock

Mario Fusco (Jira) issues at jboss.org
Thu Nov 22 11:51:00 EST 2018


     [ https://issues.jboss.org/browse/DROOLS-3337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mario Fusco resolved DROOLS-3337.
---------------------------------
    Resolution: Explained


You're creating the KieSession in the wrong way.

If you do 

{code}
KieBase kbase = kieContainer.getKieBase("rules");
KieSession ksession = kbase.newKieSession(null, env);
{code}

the session is not under the control of the kiecontainer and then cannot take the conf in kmodule file. Conversely if you create the kiesession directly from the container like in:

{code}
KieSession ksession = kieContainer.newKieSession("ksession-rules", env);
{code}

then the session can be initialized with what defined in the kmodule file.

Note that your reproducer was wrong anyway because you missed to specify clockType="pseudo" in the kmodule.xml 

> ClassCastException while using SessionPseudoClock
> -------------------------------------------------
>
>                 Key: DROOLS-3337
>                 URL: https://issues.jboss.org/browse/DROOLS-3337
>             Project: Drools
>          Issue Type: Bug
>          Components: core engine
>    Affects Versions: 6.1.0.Final
>            Reporter: Bishnu Shankar Pandey
>            Assignee: Mario Fusco
>            Priority: Major
>         Attachments: RuleEngineTest (2).zip
>
>
> I am using 6.1.0.Final version of Drool. I am getting
> {code:java}
> java.lang.ClassCastException: org.drools.core.time.impl.JDKTimerService cannot be cast to org.drools.core.time.SessionPseudoClock
> {code}
> exception when I am trying to get session clock from the KieSession.
> I am using Persistence and getting the KieSession using this
> {code:java}
> val kieSession = kieServices.getStoreServices.newKieSession(kiebase,null,environment);
> {code}
> My kmodule.xml is:
> {code:java}
> <kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
>     <kbase name="rules" packages="rules" eventProcessingMode="stream">
>         <ksession name="ksession-rules" clockType="pseudo"/>
>     </kbase>
> </kmodule>
> {code}



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list