7 Replies Latest reply on Jan 21, 2008 7:58 AM by Ronald van Kuijk

    Problems with persistence factory in Hibernate

    Daniel Tamiosso Newbie

      I am trying to save my process instance made with JBPM 3.2 on PostgresSQL but a error occurs:

      953 [main] DEBUG org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: org.jbpm.context.log.variableinstance.StringUpdateLog
      7953 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
      7953 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
      7953 [main] DEBUG org.hibernate.engine.IdentifierValue - id unsaved-value: 0
      7953 [main] ERROR org.jbpm.persistence.db.DbPersistenceService - hibernate flush failed
      org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.graph.def.Node
       at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
       at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397)
       at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:242)
       at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:597)
       at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:3123)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:479)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:204)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:127)
       at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
       at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.jbpm.persistence.db.DbPersistenceService.flushSession(DbPersistenceService.java:272)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:232)
       at org.jbpm.svc.Services.close(Services.java:225)
       at org.jbpm.JbpmContext.close(JbpmContext.java:139)
       at com.br.human.jbpm.tests.ExecuteMain.main(ExecuteMain.java:54)
      7953 [main] DEBUG org.jbpm.persistence.db.DbPersistenceService - rolling back hibernate transaction
      7953 [main] ERROR org.jbpm.persistence.db.DbPersistenceService - hibernate rollback failed
      java.lang.NullPointerException
       at org.jbpm.persistence.db.DbPersistenceService.rollback(DbPersistenceService.java:304)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:234)
       at org.jbpm.svc.Services.close(Services.java:225)
       at org.jbpm.JbpmContext.close(JbpmContext.java:139)
       at com.br.human.jbpm.tests.ExecuteMain.main(ExecuteMain.java:54)
      7953 [main] DEBUG org.jbpm.persistence.db.DbPersistenceService - closing hibernate session
      7953 [main] DEBUG org.hibernate.impl.SessionImpl - closing session
      7953 [main] DEBUG org.hibernate.jdbc.ConnectionManager - performing cleanup
      7953 [main] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
      7953 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
      7953 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion
      7953 [main] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
      7953 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion
      7953 [main] ERROR org.jbpm.svc.Services - problem closing service 'persistence'
      org.jbpm.persistence.JbpmPersistenceException: hibernate flush failed
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:237)
       at org.jbpm.svc.Services.close(Services.java:225)
       at org.jbpm.JbpmContext.close(JbpmContext.java:139)
       at com.br.human.jbpm.tests.ExecuteMain.main(ExecuteMain.java:54)
      Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.graph.def.Node
       at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
       at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397)
       at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:242)
       at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:597)
       at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:3123)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:479)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:204)
       at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:127)
       at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
       at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.jbpm.persistence.db.DbPersistenceService.flushSession(DbPersistenceService.java:272)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:232)
       ... 3 more
      


      Any ideas?

      Thanks...

        • 1. Re: Problems with persistence factory in Hibernate
          Ronald van Kuijk Master

          yes,

          The reason is: Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance -
          save the transient instance before flushing: org.jbpm.graph.def.Node


          But that is probably not what you wanted to hear. For us to give a better answer you have to post your code and the processdefinition

          • 2. Re: Problems with persistence factory in Hibernate
            Alexandru Enache Newbie

            Hi there Ronald,

            Hope you can give me a hint on this. I have the same problem as daniel. My stacktrace is lot bigger, but it contains also the part you are talking about (with the org.hibernate.TransientObjectException). What am I doing is trying to create at runtime a ProcessDefinition and persist it. Here is the part that does this:

            JbpmConfiguration jbpmConfig = null;
             JbpmContext jbpmContext = null;
             try {
             jbpmConfig = JbpmConfiguration.getInstance();
             jbpmContext = jbpmConfig.createJbpmContext();
             System.out.println(jbpmContext==null);
             ProcessDefinition pd = ProcessDefinition.parseXmlString(
             "<process-definition name=\"pd-name\">" +
             " <start-state>" +
             " <transition to='s' />" +
             " </start-state>" +
             " <state name='s'>" +
             " <transition to='end' />" +
             " </state>" +
             " <end-state name='end' />" +
             "</process-definition>");
             ProcessInstance processInstance = new ProcessInstance(pd);
             jbpmContext.save(processInstance);
            // jbpmContext.deployProcessDefinition(pd);
            // jbpmContext.deployProcessDefinition(pd);
             }
             catch(Exception e) {
             e.printStackTrace(pw);
             }
             finally {
             if (jbpmContext!=null) {
             jbpmContext.close();
             }
             }


            The two commented lines of code where my first approach on this matter but they had the same outcome. (this is only as a test and the ProcessDefinition creation was taken from chapter 3 of the online jbpm tutorial)

            If you need any further info on this to make it clearer for you please tell me so. I really need to make this work (it's for my BSc project and the deadline is closing in on me:D). Thanks a lot for your time and hope to hear from you.

            • 3. Re: Problems with persistence factory in Hibernate
              Ronald van Kuijk Master

              Please have a look at the unit tests. This is such a basic example that I'd suggest to run those first, configured to use your database. If those run, try finding the ones that correspond to your case. If they do not run, please let us know

              • 4. Re: Problems with persistence factory in Hibernate
                Alexandru Enache Newbie

                Many many thanks Ronald,

                It appears that the stack trace was not only for the persistence of the ProcessDefinition. I've set Hibernate to output the queries and it was persisting the jbpm classes correctly. The problem was that after that step I was using the hibernate session to do some other tasks. And since one of those tasks was failing it threw some errors and hibernate was rolling back the jbpm classes. I've removed the piece of code with the hibernate session and now the jbpm classes are in the db. I only need now to find out why that piece of code is not working because I need it to work.

                Even though you haven't provided me with an exact solution you helped me find one, and this is as good as a solution. Thanks a lot Ronald! I wish you best.

                • 6. Re: Problems with persistence factory in Hibernate
                  Daniel Tamiosso Newbie

                  Thank you also, I am now trying to integrate the jBPM with Spring. Any hint will be welcome, thank you!

                  • 7. Re: Problems with persistence factory in Hibernate
                    Ronald van Kuijk Master

                    the jbpm-spring integration is written by the spring guys. You stand a better chance asking there.