5 Replies Latest reply on Jun 19, 2012 4:14 PM by Mauricio Salatino

    Unable to dispose ksession

    Dsire krish Newbie

      My workflow process operations happens asynchronously.

      Creating a process instance and completing a task happens seperately.

      So i couldnt identify a idle time to dispose the knowledge session.

      Kindly help with a way to dispose the session.

        • 1. Re: Unable to dispose ksession
          Mauricio Salatino Master

          are you using persistence right?

          If you are using persistance you can dispose the session and load it back when you are sure that the thread that was using the session will not use it anymore.

          Cheers

          1 of 1 people found this helpful
          • 2. Re: Unable to dispose ksession
            Dsire krish Newbie

            Yeah thats right.I got your point.

            But in my case the starting of a process and completion of it happens parallely.

            And when i do so as u said. i'm getting this hibernate exception due to optimistic lock.

             

            javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.drools.persistence.info.SessionInfo#1]

                      at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:630)

                      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:588)

             

            and im looking for a way to clear this exception.

            • 3. Re: Unable to dispose ksession
              Mauricio Salatino Master

              How do you usually solve a problem when you have 2 or more threads against 1 database that is locking?

              I think that's the answer to your question.. sorry to answer with another question

              Cheers

              • 4. Re: Unable to dispose ksession
                Dsire krish Newbie

                For starting the process, the ksession associated with the taskhandler should be alive.

                And by the same time during the completion of the task the ksession should be alive.

                As both these shares the same taskhandler i couldnt dispose the ksession.

                 

                Hence i thought of having seperate taskhandlers one for starting a process and other for completing a task.

                Thats in where i got that optimistic lock exception.

                 

                1. Cant  i dispose the ksession with shared taskhandler.?

                2. If i gotto use seperate taskhandlers, How to correct this exception.?

                • 5. Re: Unable to dispose ksession
                  Mauricio Salatino Master

                  You can load the session and add a new instance of the task handler for the newly hydrated session, you don't need to share the WorkItemHandler between the two.

                  Cheers