0 Replies Latest reply on Jun 4, 2012 2:48 AM by Pavel Sknar

    Concurrent modification exception

    Pavel Sknar Newbie

      I have exception in JBPM 5.3 with using spring configuration.

       

      public class ExecuteWorkItemHandler implements WorkItemHandler {

           private TaskHandler taskHandler;

           private ProcessManager processManager;

      ........

          @Override

          public void executeWorkItem(final WorkItem workItem, final WorkItemManager manager) {

                new Thread(new Runnable() {

                  @Override

                  public void run() {

                     try {

                          result = taskHandler.execute(parameters);

                      } catch (Throwable th) {

                          log.error("Failed execute task handler: {} ({})", workItem.getId(), workItem.getName());

                          log.error("", th);

                      }

                      parameters.put("Result", result);

                      try {

                          processManager.completeWorkItem(workItem.getId(), parameters); // TODO Exception there

                      } catch (Throwable th) {

                          log.error("Exception in work item: {}", workItem.getName());

                          og.error("", th);

                      }

                  }

               }).start();

          }

      }

       

      Exception in work item: TestTask

      .....

      Caused by: javax.persistence.RollbackException: Error while committing the transaction                                                                                             

      at  org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:93)                                                                                                       

      at  org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerSynchronization.afterCommit(ExtendedEntityManagerCreator.java:478)                        

      ... 24 more             

      Caused by: java.util.ConcurrentModificationException                                                                                                                               

      at  java.util.HashMap$HashIterator.nextEntry(HashMap.java:806)                                                                                                              

      at  java.util.HashMap$KeyIterator.next(HashMap.java:841)                                                                                                                    

      at  org.drools.marshalling.impl.OutputMarshaller.writeWorkItem(OutputMarshaller.java:1078)                                                                                  

      at  org.drools.persistence.info.WorkItemInfo.update(WorkItemInfo.java:134)                                                                                                  

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                                                             

      at  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)                                                                                           

      at  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                                                                   

      at  java.lang.reflect.Method.invoke(Method.java:601)                                                                                                                        

      at  org.hibernate.ejb.event.BeanCallback.invoke(BeanCallback.java:37)                                                                                                       

      at  org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:94)                                                                                   

      at  org.hibernate.ejb.event.EntityCallbackHandler.preUpdate(EntityCallbackHandler.java:79)                                                                                  

      at  org.hibernate.ejb.event.EJB3FlushEntityEventListener.invokeInterceptor(EJB3FlushEntityEventListener.java:61)                                                            

      at  org.hibernate.event.def.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:349)                                                    

      at  org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:287)                                                        

      at  org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:155)                                                         

      at  org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)                                                             

      at  org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)                                                

      at  org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)                                                                            

      at  org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)                                                                                                             

      at  org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)                                                                                                       

      at  org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)                                                                                              

      at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)