org.hibernate.exception.ConstraintViolationException on deleting process instances in jBPM3
Issue
I have tried to use the solution (supplied as a quickstart) in the following link Is there a way to automatically clean the jBPM tables from ended process instances?.
I get the following stack trace.
2013-07-01 12:18:00,729 ERROR [org.hibernate.util.JDBCExceptionReporter] (ESBScheduler:jbpm_maintenance.esb_Worker-0) Cannot delete or update a parent row: a foreign key constraint fails (`xxx`.`JBPM_TOKEN`, CONSTRAINT `FK_TOKEN_PROCINST` FOREIGN KEY (`PROCESSINSTANCE_`) REFERENCES `JBPM_PROCESSINSTANCE` (`ID_`))
2013-07-01 12:18:00,729 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] (ESBScheduler:jbpm_maintenance.esb_Worker-0) Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.graph.exe.ProcessInstance#1903]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2559)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2715)
at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:96)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:278)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:171)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:999)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1185)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.jbpm.db.GraphSession.deleteTasks(GraphSession.java:468)
at org.jbpm.db.GraphSession.deleteProcessInstance(GraphSession.java:425)
at org.jbpm.db.GraphSession.deleteProcessInstance(GraphSession.java:400)
at org.jboss.soa.esb.samples.quickstart.jbpm.maintenance.DeleteOldJbpmProcessInstancesAction.deleteOldProcessInstance(DeleteOldJbpmProcessInstancesAction.java:135)
at org.jboss.soa.esb.samples.quickstart.jbpm.maintenance.DeleteOldJbpmProcessInstancesAction.onSchedule(DeleteOldJbpmProcessInstancesAction.java:91)
at org.jboss.soa.esb.listeners.ScheduleListener.onSchedule(ScheduleListener.java:121)
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`xxx`.`JBPM_TOKEN`, CONSTRAINT `FK_TOKEN_PROCINST` FOREIGN KEY (`PROCESSINSTANCE_`) REFERENCES `JBPM_PROCESSINSTANCE` (`ID_`))
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:365)
...
2013-07-01 12:18:00,731 ERROR [org.jboss.soa.esb.samples.quickstart.jbpm.maintenance.DeleteOldJbpmProcessInstancesAction] (ESBScheduler:jbpm_maintenance.esb_Worker-0) failed to delete process instance '1902': could not delete ProcessInstance(1902)
Environment
- Red Hat JBoss SOA Platform
- 5.3.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
