0 Replies Latest reply on Apr 25, 2008 6:32 PM by tak2

    NullPointerException on rollback

    tak2

      Hi,
      I have a question about jBPM behavior with external Connection.

      Configuration is as follows.
      * Set isTransactionEnabled = false to DbPersistenceServiceFactory in jbpm.cfg.xml
      * Database transaction is managed by third party framework which is not JTA, which is simple connection based local transaction with template method pattern.
      * Provided the external Connection via JbpmContext.setConnection method
      * Commented out all JDBC connection properties in hinernate.cfg.xml
      * Create our own ConnectionProvider to provide the external Connection, and set it to "hibernate.connection.provider_class" in hinernate.cfg.xml

      With this environment, when hibernate throws Exception, DbPersistenceService thorws NullPointerException, and here is the stack trace.
      java.lang.NullPinterException
      at org.jbpm.persistence.db.DbPersistenceService.rollbak(DbPersistenceService.java:304)
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:234)
      at org.jbpm.svc.service.close(service.java:225)
      at org.jbpm.JbpmContext.close(JbpmContext.java:139)

      It is happening because "transaction" field is NULL, because it's set when isTransactionEnable = true in beginTransaciton method when getSessiojn method is called.

      I don't know very much about DbPersistenceService, but the code of close method doesn't add up. First block of code is wrapped by if stement with (isTransactionEnabled && (transaction != null)), which is good, but rest of the section three is no check against this condition and rollback method is called, and of course transaction field is NULL.

      I'm not sure this check must be in close method or in rollback method, but this check should be in place somewhere to be consistent for isTransactionEnable.

      Is my grasp right? and is three anybody who has already solved this issue?

      thanks,