2 Replies Latest reply on Jan 30, 2007 4:41 PM by crussell42

    Question about retrieving User Object from ExecutionContext

    romeufigueira

      So, I've got this object:

      public class MySerializableClass implements java.io.Serializable {
      
       private static final long serialVersionUID = 1L;
      
       int member;
      
       public MySerializableClass(int member){
       this.member = member;
       }
      
       public boolean equals(Object o) {
       if (! (o instanceof MySerializableClass)) return false;
       return ( member == ((MySerializableClass)o).member );
       }
      }


      which I put into the context in a certain node by:

      context.setVariable("a", new MySerializableClass(4));


      and then further down the workflow, I try to retrieve through this operation:
      MySerializableClass msc = (MySerializableClass) context.getVariable("a");


      And this operation leads to this error:
      java.lang.ClassCastException: common.types.MySerializableClass
       at jbpm.notifications.InsertEvent_ActionHandler.execute(InsertEvent_ActionHandler.java:55)
       at org.jbpm.graph.def.Action.execute(Action.java:123)
       at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
       at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:212)
       at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:182)
       at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:166)
       at org.jbpm.graph.def.Node.enter(Node.java:301)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:205)
       at org.jbpm.graph.def.Node_$$_javassist_46.enter(Node_$$_javassist_46.java)
       at org.jbpm.graph.def.Transition.take(Transition.java:119)
       at org.jbpm.graph.def.Node.leave(Node.java:383)
       at org.jbpm.graph.exe.ExecutionContext.leaveNode(ExecutionContext.java:136)
       at org.jbpm.graph.node.Decision.execute(Decision.java:146)
       at org.jbpm.graph.def.Node.enter(Node.java:316)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:205)
       at org.jbpm.graph.def.Node_$$_javassist_46.enter(Node_$$_javassist_46.java)
       at org.jbpm.graph.def.Transition.take(Transition.java:119)
       at org.jbpm.graph.def.Node.leave(Node.java:383)
       at org.jbpm.graph.node.StartState.leave(StartState.java:70)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:205)
       at org.jbpm.graph.def.Node_$$_javassist_46.leave(Node_$$_javassist_46.java)
       at org.jbpm.graph.exe.Token.signal(Token.java:178)
       at org.jbpm.graph.exe.Token.signal(Token.java:123)
       at vvp.ws.notifications.NotificationsWS.Notify(NotificationsWS.java:122)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ws.server.ServiceEndpointInvokerJSE.invokeServiceEndpoint(ServiceEndpointInvokerJSE.java:91)
       at org.jboss.ws.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:151)
       at org.jboss.ws.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:195)
       at org.jboss.ws.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:373)
       at org.jboss.ws.server.StandardEndpointServlet.doPost(StandardEndpointServlet.java:116)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at org.jboss.ws.server.StandardEndpointServlet.service(StandardEndpointServlet.java:77)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)


      Now, I've searched the forums, and the best awnser that I've got was this one from JoeDeveloper:
      http://blogs.sourceallies.com/roller/page/joedeveloper?entry=jbpm_3_1_auto_user

      Now, I've tried his approach and still no go, so what possibly could be wrong here?

      PS: My class is taken from the jbpm examples (VariableInstanceDbTest.java), which doesnt try to get the object back, only does an assertEquals.

        • 1. Re: Question about retrieving User Object from ExecutionCont
          romeufigueira

          Further info:

          jBPM 3.1.4
          Oracle DB

          and that "context" var that you see is an ExecutionContexttype of var.

          • 2. Re: Question about retrieving User Object from ExecutionCont
            crussell42

            I tried the following trick (total guess, Not sure it will work but it got me a little further). Seems like this scheme should work to force jbpm to consider the user object as a hibernatable object...which mine is only not because of hibernate.cfg.xml
            jbpm.varmapping.xml

             <jbpm-type>
             <matcher>
             <bean class="org.jbpm.context.exe.matcher.ClassNameMatcher">
             <field name="className"><string value="foo.MyFooClass" /></field>
             </bean>
             </matcher>
             <variable-instance class="org.jbpm.context.exe.variableinstance.HibernateLongInstance" />
             </jbpm-type>
            


            This now causes me to get a
            org.hibernate.MappingException: Unknown entity: foo.MyFooClass
            

            So I guess I somehow need to get MyFooClass into the classloader path of the jbpm-enterprise.ear I am deploying....Any thoughts appreciated.
            This tends to make me believe that at least jbpm is trying to treat my Entity as a hibernatable object. However, I just use the javax.persistence and annotations so I dont have a hibernate.cfg.xml in my ejb3 / pojo foo.jar.
            I guess I dont know what the HibernateLongIdMatcher really does. Seems it would use introspection and look for an org.hibernate.annotations.Id? -or- Entity. Or does it just look for a match of the class name in some hibernate.cfg.xml that it finds?