1 Reply Latest reply on Sep 21, 2006 3:24 PM by Roman

    Issue with jBPM and EJB3 RC9 FD?

    Scott McNab Newbie

      Hello.

      Since upgrading from EJB3 RC8 to RC9 on JBossAS4.0.4.GA, I am getting a new exception with jBPM in code that was previously working fine (using both jBPM 3.1.1 and jBPM 3.1.2).

      The exception I am getting is unusual (full exception trace shown at the end of this post):


      Exception: javax.ejb.EJBTransactionRolledbackException: javax.persistence.PersistenceException: org.hibernate.HibernateException: instance not of expected entity type: org.jbpm.graph.def.Node_$$_javassist_118 is not a: org.jbpm.graph.def.Node


      This makes me think there could be an issue with jBPM and the new version of Hibernate used in EJB3 RC9?

      The code in question is a @Stateless session bean method (with an injected @PersistenceContext EntityManager) that uses a JbpmContext to create and start a jBPM workflow process.

      This code is slightly unconventional, in that I am explicitly sharing the injected EntityManager's hibernate session with the JbpmContext, so as to avoid creating a nested transaction. The code excerpt for this from the SLSB is as follows:

      // Injected EntityManager
      @PersistenceContext protected EntityManager em;
      ....
      public long createProcess(...) {
       // Share the EntityManager's hibernate session with jBPM
       JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
       HibernateEntityManager hem = (HibernateEntityManager)em.getDelegate();
       jbpmContext.setSession( hem.getSession() );
       try {
       ProcessDefinition processDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition(processDefinitionName);
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       ...
       // Initialise process context variables
       ...
       jbpmContext.save(processInstance);
       return processInstance.getId();
       } catch( ... ) { ... }
       finally {
       jbpmContext.close();
       }
      }


      I have put all the jBPM Hibernate mapping file definitions in my EJB3 persistence.xml file, and jBPM is deployed as part of my application .ear file. This configuration has been working well for months with EJB3 RC8 and earlier.

      The other part of the error which is confusing me is the nested "EntityManager must be access within a transaction" exception, which I think must be a red-herring side-effect of the initial "instance not of expected entity type" exception, as there is definitely a transaction in progress when I pass the hibernate session to the JbpmContext (as it is SLSB method code which creates the JbpmContext).

      Does anyone have any idea why I'm now getting this failure when the only change is an upgrade from EJB3 RC8 to RC9?

      Here is a full trace of the exception:


      2006-09-20 11:03:40,171 203125 ERROR [com.vieo.ccs.model.process.impl.WorkflowProcessFactoryBean] (pool-3-thread-2:) Exception: javax.ejb.EJBTransactionRolledbackException: javax.persistence.PersistenceException: org.hibernate.HibernateException: instance not of expected entity type: org.jbpm.graph.def.Node_$$_javassist_118 is not a: org.jbpm.graph.def.Node
      2006-09-20 11:03:40,171 203125 ERROR [com.vieo.ccs.model.topology.commands.StartProcessCommand] (pool-3-thread-2:) Error initialising process: ILU Assistance Call : com.vieo.ccs.model.topology.WorkflowException: javax.ejb.EJBTransactionRolledbackException: javax.persistence.PersistenceException: org.hibernate.HibernateException: instance not of expected entity type: org.jbpm.graph.def.Node_$$_javassist_118 is not a: org.jbpm.graph.def.Node
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) Exception in thread "pool-3-thread-2"
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) javax.ejb.EJBException: javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:275)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:211)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at $Proxy220.processDeviceEvent(Unknown Source)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at com.vieo.ccs.server.handlers.GatewayMessageHandler.process(GatewayMessageHandler.java:48)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at com.vieo.ccs.server.handlers.MessageHandlerFactory.processMessage(MessageHandlerFactory.java:54)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at com.vieo.ccs.server.AMQGatewayServerThread.run(AMQGatewayServerThread.java:61)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      2006-09-20 11:03:40,187 203141 ERROR [STDERR] (pool-3-thread-2:) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at java.lang.Thread.run(Thread.java:595)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) Caused by: javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.entity.ManagedEntityManagerFactory.verifyInTx(ManagedEntityManagerFactory.java:149)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.entity.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:180)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at com.vieo.ccs.model.topology.impl.GatewayConnectorBean.processDeviceEvent(GatewayConnectorBean.java:121)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at java.lang.reflect.Method.invoke(Method.java:585)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:40)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source)
      2006-09-20 11:03:40,218 203172 ERROR [STDERR] (pool-3-thread-2:) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at java.lang.reflect.Method.invoke(Method.java:585)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
      2006-09-20 11:03:40,250 203204 ERROR [STDERR] (pool-3-thread-2:) ... 22 more


      Thanks!

        • 1. Re: Issue with jBPM and EJB3 RC9 FD?
          Roman Newbie

          I don't use jBPM, I use EJB3-RC9 directly.
          I have the same exception in some cases with code which worked previously.
          Seems like "instance not of expected entity type" drops transaction somehow.
          The exception is thrown in some place in code which does not throw an exception in some cases and throws when called in slightly other way.
          Is this javaassist porblem or EJB3?