3 Replies Latest reply on Aug 6, 2014 1:53 AM by swiderski.maciej

    jbpm 6 ejb3.0 class  cannot be cast error ?

    mstknk

      Hi ,

      i got an exception while trying to access ejb interface . My implementation looks like  (i use org.kie.internal.executor.api.Command interface ) :

       

      public class TestCommand implements Command {

          public ExecutionResults execute(CommandContext ctx) {

              ExecutionResults executionResults = new ExecutionResults();

              try {

                  InitialContext ctx1 = new InitialContext();

                  DummyBeanLocal dummyBean =(DummyBeanLocal)ctx1.lookup("java:global/Test-EAR/ejb-TestBean/DummyBean!com.mst.ejb.DummyBeanLocal");

              } catch (NamingException e) {

              }

              return executionResults;

          }}

       

      The error message is :

      [org.jbpm.executor.impl.AvailableJobsExecutor] (pool-18-thread-1) Error during command ag.pst.TestCommand execution

      com.mst.ejb.DummyBeanLocal$$$view8 cannot be cast to com.mst.ejb.DummyBeanLocal

       

      is it possible to use ejb  on Command interface ?  what is the best approach to use ejb and jbpm together ?

      Any help and  tips would be greatly appreciated .

        • 1. Re: jbpm 6 ejb3.0 class  cannot be cast error ?
          swiderski.maciej

          this error indicates that your ejb bean does not implement DummyBeanLocal interface. As you can see you don't do anything special from jbpm and only use JNDI look up.

           

          So make sure it only casts to the known (implemented) interface of the bean and you should be able to use that from within command.

           

          HTH

          • 2. Re: jbpm 6 ejb3.0 class  cannot be cast error ?
            mstknk

            Hi Maciej,

             

            from my point of view this is a class loader issue.

            My ejb is deployed inside of MyApp.war. I add the interace DummyBeanLocal to my jbpm dependencies. On runtime DummyBeanLocal is loaded twice. One time with jbpm class loader and one time with MyApp.ear classloader. Therefore I got a ClassCastException.

            How I should use jbpm console to have access to ejb which is still available on my app server?

             

            Regards,

            Mesut

            • 3. Re: jbpm 6 ejb3.0 class  cannot be cast error ?
              swiderski.maciej

              if jbpm runs withing the same classloader hierarchy as you ejb then you don't need to add dependencies to kjars to be resolved on runtime, meaning you should declare it as provided so jBPM won't load that dependency when creating runtime representation of the kjar.

               

              HTH