5 Replies Latest reply on May 15, 2007 9:36 AM by Danny Shaul

    Exception - uniqeue constraint

    Danny Shaul Newbie

      Hi
      I run the following code:

       public Long startFlow(long cid,String problem, long sid) {
       Long processDefId = null;
       SupportRequest supportRequest = null;
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
      
       GraphSession graphSession = jbpmContext.getGraphSession();
      
       ProcessDefinition processDefinition =
       graphSession.findLatestProcessDefinition("Submits New Support Request");
      
       ProcessInstance processInstance =
       new ProcessInstance(processDefinition);
      
       processDefId = processDefinition.getId();
       ContextInstance contextInstance = processInstance.getContextInstance();
       contextInstance.setVariable("cid", cid);
       contextInstance.setVariable("problem", problem);
       contextInstance.setVariable("sid" , sid);
       contextInstance.setVariable("processDefId" , processDefId);
      
       log.debug("process definition Id for continuing the : "+processDefId);
      
       Token token = processInstance.getRootToken();
      
       token.signal();
      
       jbpmContext.save(processInstance);
      
       } finally {
       jbpmContext.close();
       return processDefId;
       }
       }
      



      Adn I receive the following error when running the save() operation inside the method:

      13:21:50,578 INFO [DefaultRemoter] Exec: supportRequestFlow.startSupportRequestCall()
      13:21:50,671 WARN [ProxyWarnLog] Narrowing proxy to class org.jbpm.graph.node.StartState - this operation breaks ==
      13:21:50,687 WARN [ProxyWarnLog] Narrowing proxy to class org.jbpm.graph.node.State - this operation breaks ==
      13:21:50,890 WARN [JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
      13:21:50,890 ERROR [JDBCExceptionReporter] ORA-00001: unique constraint (ERAN_JBPM.SYS_C0041193) violated
      
      13:21:50,890 WARN [JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
      13:21:50,890 ERROR [JDBCExceptionReporter] ORA-00001: unique constraint (ERAN_JBPM.SYS_C0041193) violated
      
      13:21:50,890 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:71)
       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
       at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:218)
       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2159)
       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2595)
       at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at org.jbpm.persistence.db.DbPersistenceService.commit(DbPersistenceService.java:253)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:211)
       at org.jbpm.svc.Services.close(Services.java:222)
       at org.jbpm.JbpmContext.close(JbpmContext.java:139)
       at com.supportspace.stargate.service.impl.jbpm.SupportRequestFlowImpl.startSupportRequestCall(SupportRequestFlowImpl.java:87)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
       at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:423)
       at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:426)
       at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:280)
       at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
       at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
       at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:120)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:75)
       at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:89)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at com.opensymphony.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:42)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
       at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
       at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
       at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
       at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
       at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
       at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
       at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
       at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:106)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
       at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:229)
       at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
       at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
       at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:173)
       at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (ERAN_JBPM.SYS_C0041193) violated
      
       at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
       at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10698)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
       ... 84 more
      13:21:50,890 ERROR [DbPersistenceService] hibernate commit failed
      org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
       at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:218)
       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2159)
       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2595)
       at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
      



      I debug it and it seems the uniqeue constraint error I receives is due to the fact the process definition returns is already exists in DB.
      I based the code on the example 3.2 from jboss site http://docs.jboss.com/jbpm/v3/userguide/tutorial.html
      how the persistency works? why it creates new processDefinition entry each time?