1 Reply Latest reply on Jan 28, 2008 6:24 AM by anuragpaliwal

    Unable to close jbpmContext - help !

    francis1970

      Dear all,
      I have a web application which is front-end for a JBPM process.
      When a Task Node is reached, an assignment handler is fired.
      This simply persist some information on the DataBase to keep track of the assignment.

      The problem is that, when JbpmContext is closed() an exception is raised.....

      org.jbpm.JbpmException: problem closing services {persistence=org.jbp
      m.persistence.JbpmPersistenceException: hibernate commit failed}


      this is the code of the AssignmentHandler

      public class SimpleAssignmentHandler implements AssignmentHandler {
       private static final long serialVersionUID = 1L;
       public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
      
       assignable.setActorId("username");
      
       JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
       JbpmContext ctx = jbpmConfiguration.createJbpmContext();
      
       Session session = ctx.getSession();
       Query query = session.createQuery("from Test");
      
       Test test = (Test)(query.list().get(0));
      
       session.beginTransaction();
      
       test.setName("name");
       test.setSurname("surname");
      
       session.getTransaction().commit();
       session.close();
      
       ctx.close(); // Exception is raised here
       }
       }


      I'm using JBPM 3.2 deployed on JBoss 4.2.0.....
      Any ideas ? thanks a lot
      Francesco

        • 1. Re: Unable to close jbpmContext - help !
          anuragpaliwal

          Hi Francesco

          Recomended way of using jbpmContext is to put it inside try{}finally{} block.

          try{

          //Do Stuff

          }finally{

          //Close context
          }

          I gues you donot need to demarcate transaction boundry here. jbpmContext.close() would commit and close the session as well.

          Shout if it doesn't work