8 Replies Latest reply on Dec 19, 2005 10:02 AM by kukeltje

    randomly get Exception

    camunda

      Very strange thing:

      from time to time we get a expeception while doing something with jBPM (in this example deploy a process, so this is not more that persist a few objects with hibernate):

      12:21:32,452 WARN [JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
      12:21:32,452 ERROR [JDBCExceptionReporter] ORA-00001: unique constraint (BERND.SYS_C00581420) violated
      
      12:21:32,452 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
      


      The constraint lays on the JBPM_TRANSITION table.

      As I check the logs everthings looks right:
      2005-12-16 13:48:12,843 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
      [...]
      2005-12-16 13:48:12,843 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
      2005-12-16 13:48:12,843 INFO [com.camunda.tk-jbpm.services.AdminServicesImpl] deployment sucessfull
      2005-12-16 13:48:12,843 INFO [STDOUT] Hibernate: insert into JBPM_PROCESSDEFINITION (NAME_, VERSION_, ISTERMINATIONIMPLICIT_, STARTSTATE_, ID_) values (?, ?, ?, ?, ?)
      2005-12-16 13:48:12,843 INFO [STDOUT] Hibernate: insert into JBPM_NODE (NAME_, PROCESSDEFINITION_, ACTION_, SUPERSTATE_, CLASS_, ID_) values (?, ?, ?, ?, 'R', ?)
      [...]
      2005-12-16 13:48:12,913 INFO [STDOUT] Hibernate: insert into JBPM_TRANSITION (NAME_, PROCESSDEFINITION_, FROM_, TO_, ID_) values (?, ?, ?, ?, ?)
      2005-12-16 13:48:12,913 INFO [STDOUT] Hibernate: insert into JBPM_TRANSITION (NAME_, PROCESSDEFINITION_, FROM_, TO_, ID_) values (?, ?, ?, ?, ?)
      


      But while commiting the exception occurs. I think it is something wrong with the ID-Generating? As I looked into jbpm-sources it is
      <id name="id" column="ID_"><generator class="native" /></id>
      , should be ok. We use the dialect: org.hibernate.dialect.Oracle9Dialect

      Then, if I want to deploy the process after the rollback, I get another error:
      2005-12-16 16:10:53,463 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
      2005-12-16 16:10:53,463 ERROR [org.jbpm.db.GraphSession] org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [org.jbpm.graph.def.ProcessDefinition#1]
      


      I am sorry, but I am not the hibernate champ (I favour JDO ;-)), so any hints to this?

      We have seen this exception randomly occur in other contextes (on other jBPM tables) but doesn't have not succesfully written a test, which fails every time...

      Thanks a lot!

        • 1. Re: randomly get Exception
          sforema

          What version of jBPM are you running? I am using 3.0 and I've never seen that error and I've been testing the h3ll out of it.

          Sean

          • 2. Re: randomly get Exception
            camunda

            we use "jbpm 3.0.2"

            I have worked on a nother project with mySQL and also does not have seen it before. Very, very strange things happen....

            • 3. Re: randomly get Exception
              sforema

              Also... be careful with your transactions. Objects are (generally) tied to the hibernate sesion they came from. Always keep that in mind when dealing with the session and objects. If you open two sessions, you could have objects bound to the wrong session. Or if you close a session, fiddle with an object and then open it, you could also have trouble.

              That may have nothing to do with what you're seeing, but just in case...

              • 4. Re: randomly get Exception
                camunda

                Ah OK, should have mentioned it: we run in JBoss and use JTA, so we get our session from there (sessionFactory.getCurrentInstance()).

                The call which failes is in one SessionBean-call, so this should not be the cause of trouble...

                • 5. Re: randomly get Exception
                  sforema

                  Have you looked at the BERND.SYS_C00581420 constraint to see specifically what it is? is it trying to put the same row in twice?

                  • 6. Re: randomly get Exception
                    camunda

                    Yes, it is the UNIQUE index constraint on the ID_ column, so jbpm wants to put in two rows in the JBPM_TRANSITION - table with the same ID_ (which was generated over the Oracle sequence when working with "native" I think).

                    But why?

                    • 7. Re: randomly get Exception
                      camunda

                      OK, I think I have found a solution, that seems to work.

                      configure the Interval & Cache-Size of the oracle-sequence ("HIBERNATE_SEQUENCE" per default) to the same size.

                      For example

                      ALTER SEQUENCE "BERND"."HIBERNATE_SEQUENCE" CACHE 50 NOMAXVALUE INCREMENT BY 50
                      


                      • 8. Re: randomly get Exception
                        kukeltje

                        good catch. Didn't know hibernate had this option. We use it a lot in Bea/Oracle.