Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-278

ProtobufMarshaller throws ClassCastException when marshalling CDI proxied KieSession.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 6.0.0.CR3
    • None
    • None

    Description

      I have a CDI (Weld) @Producer which produces a KieSession. The KieSession is therefore proxied by a CDI/Weld proxy. When I try to marshall such a KieSession object, the ProtobufMarshaller throws the following ClassCastException:

      01:21:07.505 [main] ERROR o.j.d.b.c.CdiSessionPersistenceTest - Error saving KieSession.
      java.lang.ClassCastException: org.jboss.weld.proxies.CommandExecutor$EntryPoint$KieRuntime$KieRuntimeEventManager$KieSession$ProcessEventManager$ProcessRuntime$RuleRuntime$StatefulProcessSession$StatefulRuleSession$WorkingMemoryEventManager$761192450$Proxy$_$$_WeldClientProxy cannot be cast to org.drools.core.impl.StatefulKnowledgeSessionImpl
      at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:157) ~[drools-core-6.0.0.CR4-Pre1.jar:6.0.0.CR4-Pre1]
      at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:148) ~[drools-core-6.0.0.CR4-Pre1.jar:6.0.0.CR4-Pre1]
      at org.jboss.ddoyle.brms.cep.ha.management.FileKieSessionLoader.save(FileKieSessionLoader.java:67) ~[classes/:na]
      at org.jboss.ddoyle.brms.cep.ha.management.FileKieSessionLoader.save(FileKieSessionLoader.java:37) ~[classes/:na]
      at org.jboss.ddoyle.brms.cep.ha.drools.session.SessionManager.saveKieSession(SessionManager.java:27) ~[classes/:na]
      at org.jboss.ddoyle.brms.cep.ha.drools.session.SessionManager$Proxy$$$_WeldClientProxy.saveKieSession(SessionManager$Proxy$$$_WeldClientProxy.java) ~[classes/:na]
      at org.jboss.ddoyle.brms.cdi.CdiSessionPersistenceTest.testCdiSessionPersistence(CdiSessionPersistenceTest.java:43) ~[test-classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_40]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_40]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_40]
      at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_40]
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) [junit-4.11.jar:na]
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.11.jar:na]
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) [junit-4.11.jar:na]
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.11.jar:na]
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) [junit-4.11.jar:na]
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) [junit-4.11.jar:na]
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) [junit-4.11.jar:na]
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) [junit-4.11.jar:na]
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) [junit-4.11.jar:na]
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) [junit-4.11.jar:na]
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) [junit-4.11.jar:na]
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) [junit-4.11.jar:na]
      at org.junit.runners.ParentRunner.run(ParentRunner.java:309) [junit-4.11.jar:na]
      at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) [surefire-junit4-2.10.jar:2.10]
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) [surefire-junit4-2.10.jar:2.10]
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) [surefire-junit4-2.10.jar:2.10]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_40]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_40]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_40]
      at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_40]
      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) [surefire-api-2.10.jar:2.10]
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) [surefire-booter-2.10.jar:2.10]
      at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175) [surefire-booter-2.10.jar:2.10]
      at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107) [surefire-booter-2.10.jar:2.10]
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68) [surefire-booter-2.10.jar:2.10]

      I've created a reproducer which shows the behaviour: https://github.com/DuncanDoyle/DroolsSessionCdiClassCastException

      Just run 'mvn clean test' in the project.

      Attachments

        Activity

          People

            rhn-gps-ddoyle Duncan Doyle (Inactive)
            rhn-gps-ddoyle Duncan Doyle (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: