1 Reply Latest reply on Jun 14, 2006 2:18 AM by r y

    Creating JbpmContext into an Action

    r y Newbie

      Hi, ...

      I am doing something like that:

      In an action (that implements ActionHandler), in some point of execution, I create a new JpbmContext with this:

      JbpmContext jbpmContext_new = org.jbpm.JbpmConfiguration.getInstance().createJbpmContext();


      I do that, because I want to do a bunch of modifications in the Database, but every one is done separately, and if one fails, the other will rollback too. In every case, the process go on (with error or success in database changes) to the next node. This is the reason why I don't use the current JbpmContext (
      JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
      ) and create a new one.

      The problem appears when I try to close the second JpbmContext, and then, execute the "
      executionContext.leaveNode();
      " statement I get the next log:

      17:05:54,620 INFO [SchedulerThread] runtime exception while executing timers
      org.jbpm.JbpmException: closed JbpmContext in different order then they were created... check your try-finally's around JbpmContexts blocks
      at org.jbpm.JbpmContext.popThisContextFromTheStack(JbpmContext.java:503)
      at org.jbpm.JbpmContext.close(JbpmContext.java:140)
      at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
      at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)


      I don't close the "currentJpbmContext", only the one that I created for my own purposes. I have to say that the signalling to the current token come from a timeout of a Timer.

      ¿I cannot create a JbpmContext into an action that is being executed in other JbpmContext created previously by de Jbpm engine???

      I hope you understand me... thanks you very much.


        • 1. Re: Creating JbpmContext into an Action
          r y Newbie

          No ideas? ... :-(

          I think it could be a bug in SchedulerThread, because I get the exception only when the process flow triggered by a time-out.
          The problem appears when I try to close my JbpmContext or the Hibernate Session (I have tryed a lot of ways to do my pourposes). At that moment, ... the console output shows how it "don't do anything", and in a few moments, I get the exception:


          08:12:42,025 WARN [JDBCExceptionReporter] SQL Error: 1205, SQLState: 41000
          08:12:42,025 ERROR [JDBCExceptionReporter] Lock wait timeout exceeded; try restarting transaction
          08:12:42,025 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
          org.hibernate.exception.GenericJDBCException: could not update: [org.jbpm.graph.exe.Token#19565]
          at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
          at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
          at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
          at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2222)
          at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
          at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
          at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
          at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
          at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
          at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
          at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
          at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
          at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
          at org.jbpm.svc.Services.close(Services.java:211)
          at org.jbpm.JbpmContext.close(JbpmContext.java:138)
          at org.jbpm.web.JbpmContextFilter.doFilter(JbpmContextFilter.java:85)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.jbpm.webapp.filter.LogFilter.doFilter(LogFilter.java:38)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
          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.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
          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:856)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
          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:534)
          Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
          at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
          at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
          at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1120)
          at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:675)
          at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1162)
          at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1079)
          at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1064)
          at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
          ... 37 more


          It only occurs whe I execute the database updates action in a token triggered by a timer, but not when it is by an user in a decision request.

          Thanks you for reading this.