1 Reply Latest reply on Nov 28, 2013 3:25 AM by swiderski.maciej

    Referential integrity constraint violation: "FK1EE418D2C122ED2: PUBLIC.PEOPLEASSIGNMENTS_POTOWNERS FOREIGN KEY(ENTITY_ID) REFERENCES PUBLIC.ORGANIZATIONALENTITY(ID)"

    bigos

      Hello.

      I'm training myself in using jBPM 5.4 in web apps. I have configured a project to use H2 database. I have a simple workflow with one script task and two human tasks. The human task service is started by hand like that:

      EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");
        TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
        HornetQTaskServer server = new HornetQTaskServer(taskService, 5153);
        Thread t = new Thread(server);
        t.start();
      

       

      When the token arrives at the first human task node this exception is thrown:

      javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: Referential integrity constraint violation: "FK1EE418D2C122ED2: PUBLIC.PEOPLEASSIGNMENTS_POTOWNERS FOREIGN KEY(ENTITY_ID) REFERENCES PUBLIC.ORGANIZATIONALENTITY(ID)"; SQL statement: insert into PeopleAssignments_PotOwners (task_id, entity_id) values (?, ?)

      in a long exception chain that I have pasted here: http://pastebin.com/eYsHDHTj

      This is my process definition: http://pastebin.com/PYYXb6Te

      It was generated by an eclipse plugin so it might be a bit errorneous and if it is I'd be grateful for pointing that out.

       

      Now, I have read that this kind exception is caused by trying to assign a task to a user that wasn't defined. In my process definition potential owners are "bolek" and "janusz", and to be sure they are present I do this:

      TaskServiceSession taskSession = taskService.createSession();
      taskSession.addUser(new User("Administrator"));
      taskSession.addGroup(new Group("mods"));
      taskSession.addUser(new User("janusz"));
      taskSession.addUser(new User("bolek"));
      

       

      It runs and gives me that log:

      12:07:21,552 INFO  [stdout] (MSC service thread 1-6) Hibernate: select user0_.id as id62_0_ from OrganizationalEntity user0_ where user0_.id=? and user0_.DTYPE='User'

       

       

      12:07:21,560 WARN  [org.jbpm.task.service.TaskServiceSession] (MSC service thread 1-6) User Administrator already exists in Task Server

      12:07:21,561 INFO  [stdout] (MSC service thread 1-6) Hibernate: select group0_.id as id62_0_ from OrganizationalEntity group0_ where group0_.id=? and group0_.DTYPE='Group'

       

       

      12:07:21,562 WARN  [org.jbpm.task.service.TaskServiceSession] (MSC service thread 1-6) Group mods already exists in Task Server

      12:07:21,563 INFO  [stdout] (MSC service thread 1-6) Hibernate: select user0_.id as id62_0_ from OrganizationalEntity user0_ where user0_.id=? and user0_.DTYPE='User'

       

       

      12:07:21,565 WARN  [org.jbpm.task.service.TaskServiceSession] (MSC service thread 1-6) User janusz already exists in Task Server

      12:07:21,566 INFO  [stdout] (MSC service thread 1-6) Hibernate: select user0_.id as id62_0_ from OrganizationalEntity user0_ where user0_.id=? and user0_.DTYPE='User'

       

       

      12:07:21,567 WARN  [org.jbpm.task.service.TaskServiceSession] (MSC service thread 1-6) User bolek already exists in Task Server

      I guess everything is alright with that. Also, I peeked into the database and these users exist in PUBLIC.ORGANIZATIONALENTITY table.

      What could be the reason of the exception? Everything I read about that kind of error was about not having registered potential owners of the task, which isn't the case here, I think.

      Thanks in advance for all your help. I'd be happy to provide any additional file if needed.