3 Replies Latest reply on Jun 20, 2006 9:04 AM by saish

    Hibernate TransientObjectException on JbpmContext Initial Sa

    saish

      I am getting a strange TransientObjectException (in Hibernate) when attempting to call JbpmContext#save(ProcessInstance). In specific, it is complaining of 'org.jbpm.graph.def.Node' (probably not very helpful to you guys) when the Hibernate session is closed.

      In memory, jPBM behaves fine. When attempting to persist to HSQLDB, I get the aforementioned exception. I have verified that the jPBM tables do exist in the file storing my JBoss local HSQLDB in the file system.

      This error has me totally stumped. I saw several other search hits via Google, but none when simple trying to save a ProcessInstance for the first time. Any assistance would be greatly appreciated.

      My thanks in advance,

      Saish

      --- ENVIRONMENT ---

      * HSQL DB (installed with JBoss 4)

      * jPBM 3.1

      * EJB 3.0

      * Hibernate 3.2.0-CR1 (default with JBoss 4)

      * JBoss AS 4.0.4-CR2 (installed with JBoss 4)

      * JDK 1.5

      * Windows XP

      --- JBPM HELPER IMPLEMENTATION ---

      public static final ProcessInstance startProcess(final InputStream in) {

      ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(in);
      ProcessInstance processInstance = new ProcessInstance(processDefinition);
      Token tokenRoot = processInstance.getRootToken();
      tokenRoot.signal();
      return processInstance;
      }

      public static final void saveProcess(final ProcessInstance target) {

      JbpmContext context = CONFIG.createJbpmContext();
      try {
      context.save(target);
      }
      finally {
      context.close(); // <--- CODE THAT FAILS !!!
      }
      }

      --- EJB 3.0 IMPLEMENTATION ---

      public final boolean isJbpmAlive() {

      // FIXME This is terrible. Need to inject or somehow otherwise handle elegantly.
      try {
      InputStream in = new FileInputStream("/xxx/xxx/xxx.ear/test.par/processdefinition.xml");
      return (JbpmHelper.startProcess(in) != null);
      }
      catch (IOException fatal) {
      throw new ConfigurationError("Unable to load jBPM process definition", fatal);
      }
      }

      public final boolean isJbpmPersistent() {

      // FIXME This is terrible. Need to inject or somehow otherwise handle elegantly.
      try {
      InputStream in = new FileInputStream("/xxx/xxx/xxx.ear/test.par/processdefinition.xml");
      ProcessInstance pi = JbpmHelper.startProcess(in);
      JbpmHelper.saveProcess(pi); // <--- CODE THAT FAILS
      return true;
      }
      catch (IOException fatal) {
      fatal.printStackTrace();
      return false;
      // throw new ConfigurationError("Unable to load jBPM process definition", fatal);
      }
      }

      --- PROCESSDEFINITION.XML ---

      <?xml version="1.0" encoding="UTF-8"?>

      <process-definition
      xmlns="http://jbpm.org/3/jpdl"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://jbpm.org/3/jpdl http://jbpm.org/xsd/jpdl-3.0.xsd"
      name="simple">
      <start-state name="start">

      </start-state>
      <end-state name="end"></end-state>
      <task-node name="task1">




      </task-node>
      </process-definition>

      --- JSP SCRIPTLET FRAGMENT ---


      jBPM is persisting locally? <%= local.isJbpmPersistent() %> <---- CODE THAT FAILS


      jPBM is persisting remotely? <%= remote.isJbpmPersistent() %>


      --- EXCEPTION STACK TRACE ---

      20:36:03,531 INFO [STDOUT] Hibernate: insert into JBPM_TOKEN (ID_, VERSION_, NA
      ME_, START_, END_, NODEENTER_, NEXTLOGINDEX_, ISABLETOREACTIVATEPARENT_, ISTERMI
      NATIONIMPLICIT_, ISSUSPENDED_, NODE_, PROCESSINSTANCE_, PARENT_, SUBPROCESSINSTA
      NCE_) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      20:36:03,531 INFO [STDOUT] Hibernate: call identity()
      20:36:03,531 INFO [STDOUT] Hibernate: insert into JBPM_PROCESSINSTANCE (ID_, VE
      RSION_, START_, END_, ISSUSPENDED_, PROCESSDEFINITION_, ROOTTOKEN_, SUPERPROCESS
      TOKEN_) values (null, ?, ?, ?, ?, ?, ?, ?)
      20:36:03,531 INFO [STDOUT] Hibernate: call identity()
      20:36:03,531 INFO [STDOUT] Hibernate: insert into JBPM_MODULEINSTANCE (ID_, PRO
      CESSINSTANCE_, TASKMGMTDEFINITION_, CLASS_) values (null, ?, ?, 'T')
      20:36:03,531 INFO [STDOUT] Hibernate: call identity()
      20:36:03,531 INFO [STDOUT] Hibernate: insert into JBPM_TASKINSTANCE (ID_, NAME_
      , DESCRIPTION_, ACTORID_, CREATE_, START_, END_, DUEDATE_, PRIORITY_, ISCANCELLE
      D_, ISSUSPENDED_, ISOPEN_, ISSIGNALLING_, ISBLOCKING_, TASK_, TOKEN_, SWIMLANINS
      TANCE_, TASKMGMTINSTANCE_, CLASS_) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
      , ?, ?, ?, ?, ?, ?, 'T')
      20:36:03,531 INFO [STDOUT] Hibernate: call identity()
      20:36:03,531 INFO [STDOUT] Hibernate: insert into JBPM_MODULEINSTANCE (ID_, PRO
      CESSINSTANCE_, CLASS_) values (null, ?, 'C')
      20:36:03,531 INFO [STDOUT] Hibernate: call identity()
      20:36:03,531 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, CLASS_) values (null, ?, ?, ?, ?, 'I')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, TRANSITION_, CLASS_) values (null, ?, ?, ?, ?, ?, 'S')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_) values (nu
      ll, ?, ?, ?, ?, ?, ?, ?, 'T')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, TASKINSTANCE_, CLASS_) values (null, ?, ?, ?, ?, ?, '3')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, TRANSITION_, CLASS_) values (null, ?, ?, ?, ?, ?, 'S')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_) values (null, ?, ?,
      ?, ?, ?, ?, ?, ?, 'N')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_) values (nu
      ll, ?, ?, ?, ?, ?, ?, ?, 'T')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, CLASS_) values (null, ?, ?, ?, ?, 'X')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, TASKINSTANCE_, TASKACTORID_, CLASS_) values (null, ?, ?, ?, ?,
      ?, ?, '1')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, NODE_, ENTER_, LEAVE_, DURATION_, CLASS_) values (null, ?, ?,
      ?, ?, ?, ?, ?, ?, 'N')
      20:36:03,546 INFO [STDOUT] Hibernate: call identity()
      20:36:03,546 INFO [STDOUT] Hibernate: insert into JBPM_LOG (ID_, INDEX_, DATE_,
      TOKEN_, PARENT_, TRANSITION_, SOURCENODE_, DESTINATIONNODE_, CLASS_) values (nu
      ll, ?, ?, ?, ?, ?, ?, ?, 'T')
      20:36:03,562 INFO [STDOUT] Hibernate: call identity()
      20:36:03,562 ERROR [STDERR] org.jbpm.persistence.JbpmPersistenceException: could
      n't flush hibernate session
      20:36:03,562 ERROR [STDERR] at org.jbpm.persistence.db.DbPersistenceService.
      close(DbPersistenceService.java:181)
      20:36:03,562 ERROR [STDERR] at org.jbpm.svc.Services.close(Services.java:211
      )
      20:36:03,562 ERROR [STDERR] at org.jbpm.JbpmContext.close(JbpmContext.java:1
      39)
      20:36:03,562 ERROR [STDERR] at com.xxx.xxx.xxx.integration.jbpm.JbpmHelpe
      r.saveProcess(JbpmHelper.java:61)
      20:36:03,562 ERROR [STDERR] at com.xxx.xxx.xxx.model.HeartbeatImpl.is
      JbpmPersistent(HeartbeatImpl.java:89)
      20:36:03,562 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(
      Native Method)
      20:36:03,562 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(N
      ativeMethodAccessorImpl.java:39)
      20:36:03,562 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      20:36:03,562 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5
      85)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:109)
      20:36:03,562 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntity
      ManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:98)
      20:36:03,562 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.i
      nvoke(AllowedOperationsInterceptor.java:47)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:98)
      20:36:03,562 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(T
      xPolicy.java:79)
      20:36:03,562 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.i
      nvoke(TxInterceptor.java:192)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:98)
      20:36:03,562 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor
      .invoke(TxPropagationInterceptor.java:76)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:98)
      20:36:03,562 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInt
      erceptor.invoke(StatelessInstanceInterceptor.java:54)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:98)
      20:36:03,562 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInte
      rceptor.invoke(AuthenticationInterceptor.java:78)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:98)
      20:36:03,562 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invo
      ke(ENCPropagationInterceptor.java:47)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:98)
      20:36:03,562 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInter
      ceptor.invoke(AsynchronousInterceptor.java:106)
      20:36:03,562 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:98)
      20:36:03,562 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.l
      ocalInvoke(StatelessContainer.java:181)
      20:36:03,562 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessLocalProxy.
      invoke(StatelessLocalProxy.java:79)
      20:36:03,562 ERROR [STDERR] at $Proxy74.isJbpmPersistent(Unknown Source)
      20:36:03,562 ERROR [STDERR] at org.apache.jsp.jsp.index_jsp._jspService(inde
      x_jsp.java:102)
      20:36:03,562 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service
      (HttpJspBase.java:97)
      20:36:03,562 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpSe
      rvlet.java:810)
      20:36:03,562 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.s
      ervice(JspServletWrapper.java:332)
      20:36:03,562 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJ
      spFile(JspServlet.java:314)
      20:36:03,562 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(
      JspServlet.java:264)
      20:36:03,562 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpSe
      rvlet.java:810)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterCha
      in.internalDoFilter(ApplicationFilterChain.java:252)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterCha
      in.doFilter(ApplicationFilterChain.java:173)
      20:36:03,562 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilte
      r.doFilter(ReplyHeaderFilter.java:96)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterCha
      in.internalDoFilter(ApplicationFilterChain.java:202)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterCha
      in.doFilter(ApplicationFilterChain.java:173)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve
      .invoke(StandardWrapperValve.java:213)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve
      .invoke(StandardContextValve.java:178)
      20:36:03,562 ERROR [STDERR] at org.jboss.web.tomcat.security.CustomPrincipal
      Valve.invoke(CustomPrincipalValve.java:54)
      20:36:03,562 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssocia
      tionValve.invoke(SecurityAssociationValve.java:174)
      20:36:03,562 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValv
      e.invoke(JaccContextValve.java:74)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.in
      voke(StandardHostValve.java:126)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.i
      nvoke(ErrorReportValve.java:105)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.
      invoke(StandardEngineValve.java:107)
      20:36:03,562 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.s
      ervice(CoyoteAdapter.java:148)
      20:36:03,562 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.proc
      ess(Http11Processor.java:869)
      20:36:03,562 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$H
      ttp11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      20:36:03,562 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.pr
      ocessSocket(PoolTcpEndpoint.java:527)
      20:36:03,562 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerT
      hread.run(MasterSlaveWorkerThread.java:112)
      20:36:03,562 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      20:36:03,562 ERROR [STDERR] Caused by: org.hibernate.TransientObjectException: o
      rg.jbpm.graph.def.Node
      20:36:03,562 ERROR [STDERR] at org.hibernate.engine.ForeignKeys.getEntityIde
      ntifierIfNotUnsaved(ForeignKeys.java:216)
      20:36:03,562 ERROR [STDERR] at org.hibernate.type.EntityType.getIdentifier(E
      ntityType.java:108)
      20:36:03,562 ERROR [STDERR] at org.hibernate.type.ManyToOneType.isDirty(Many
      ToOneType.java:221)
      20:36:03,562 ERROR [STDERR] at org.hibernate.type.TypeFactory.findDirty(Type
      Factory.java:476)
      20:36:03,562 ERROR [STDERR] at org.hibernate.persister.entity.AbstractEntity
      Persister.findDirty(AbstractEntityPersister.java:2900)
      20:36:03,562 ERROR [STDERR] at org.hibernate.event.def.DefaultFlushEntityEve
      ntListener.dirtyCheck(DefaultFlushEntityEventListener.java:474)
      20:36:03,562 ERROR [STDERR] at org.hibernate.event.def.DefaultFlushEntityEve
      ntListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:197)
      20:36:03,562 ERROR [STDERR] at org.hibernate.event.def.DefaultFlushEntityEve
      ntListener.onFlushEntity(DefaultFlushEntityEventListener.java:120)
      20:36:03,562 ERROR [STDERR] at org.hibernate.event.def.AbstractFlushingEvent
      Listener.flushEntities(AbstractFlushingEventListener.java:195)
      20:36:03,562 ERROR [STDERR] at org.hibernate.event.def.AbstractFlushingEvent
      Listener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
      20:36:03,562 ERROR [STDERR] at org.hibernate.event.def.DefaultFlushEventList
      ener.onFlush(DefaultFlushEventListener.java:26)
      20:36:03,562 ERROR [STDERR] at org.hibernate.impl.SessionImpl.flush(SessionI
      mpl.java:988)
      20:36:03,562 ERROR [STDERR] at org.jbpm.persistence.db.DbPersistenceService.
      close(DbPersistenceService.java:179)
      20:36:03,562 ERROR [STDERR] ... 55 more

      --- JBPM.CFG.XML ---

      <jbpm-configuration>

      <jbpm-context>






      <!--

      -->






      </jbpm-context>

      <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->

      <!-- -->












      </jbpm-configuration>

      --- HIBERNATE.PROPERTIES ---

      hibernate.dialect=org.hibernate.dialect.HSQLDialect
      hibernate.connection.driver_class=org.hsqldb.jdbcDriver
      # the sql.enforce_strict_size property is set to false by default
      # but we need it set to true for SQL standard conformance
      hibernate.connection.url=jdbc:hsqldb:C:\jboss\app_server-4.0.4.CR2\server\default\data$/hypersonic$/localDB
      hibernate.connection.username=sa
      hibernate.connection.password=

      hibernate.show_sql=true
      #hibernate.c3p0.min_size=1
      #hibernate.c3p0.max_size=3

        • 1. Re: Hibernate TransientObjectException on JbpmContext Initia
          saish

          Hmmm.... XML appears to be stripped out. Will try surrounding in comment characters.

          - Saish

          <!--
          <jbpm-configuration>

          <jbpm-context>






          <!--

          -->






          </jbpm-context>

          <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->

          <!-- -->












          </jbpm-configuration>


          -->

          • 2. Re: Hibernate TransientObjectException on JbpmContext Initia
            aguizar

            The jBPM O-R mappings do not cascade persistence operations from instances to definitions, because it assumes the user has already saved the definitions.

            Having Hibernate complain about a node being transient is a clear indication that the process definition is not saved yet. You must either call JbpmContext.deployProcessDefinition() or GraphSession.saveProcessDefinition(). The difference lies in the former assigning a version number.

            • 3. Re: Hibernate TransientObjectException on JbpmContext Initia
              saish

              Thank you so much Alex!! That did the trick nicely! Looking back, I did see that step was in the documentation, and I somehow missed it. This definitely made my Tuesday morning!

              The method itself lead me to a few other questions: how is JbpmContext.deployProcessDefinition() normally used? I am assuming it only needs to be called once per process definition deployment. Do people run an ant task as part of a buld? Ad hoc? Is there any harm in calling it multiple times?

              Thanks!

              - Saish