[jboss-user] [jBPM] - Load users and groups to Human task service

Grigory Kalabin do-not-reply at jboss.com
Mon Oct 1 08:13:36 EDT 2012


Grigory Kalabin [https://community.jboss.org/people/gkalabin] created the discussion

"Load users and groups to Human task service"

To view the discussion, visit: https://community.jboss.org/message/762488#762488

--------------------------------------------------------------
Hi everybody!

I'm using jBPM 5.3.0.Final (except jbpm-human-task which version is 5.3.0.CR1, because something is wrong with my pom.xml or maven repo) and JBoss 7.1.1.

On application startup I'm loading users and groups data to Human Task Service. Here is the code:

    private static void startHumanTaskService() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");
        TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
 
 
        // init users and groups
        TaskServiceSession taskServiceSession = taskService.createSession();
        for (String username : UsersUtils.getUsers()) {
            taskServiceSession.addUser(new User(username));
        }
        for (String group : UsersUtils.getGroups()) {
            // guest group already registered? Really?
            if (!group.equals("guest")) {
                taskServiceSession.addGroup(new Group(group));
            }
        }
 
 
        MinaTaskServer taskServer = new MinaTaskServer(taskService);
        // bind to JNDI
        try {
            new InitialContext().bind(TASK_SERVER_JNDI_NAME, taskServer);
            logger.info("save " + taskServer + " to " + TASK_SERVER_JNDI_NAME);
        } catch (NamingException exception) {
            logger.error("unable to bind task server", exception);
        }
 
 
        // start the server
        Thread thread = new Thread(taskServer);
        thread.start();
    }


But If I try load "guest" group I have the following exception


15:47:38,944 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/my-jbpm]] (MSC service thread 1-2) Exception sending context
initialized event to listener instance of class com.example.my.jbpm.MyJbpmServletContextListener: java.lang.RuntimeException: Operation failed
        at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:902) [jbpm-human-task-5.3.0.CR1.jar:5.3.0.CR1]
        at org.jbpm.task.service.TaskServiceSession.persistInTransaction(TaskServiceSession.java:868) [jbpm-human-task-5.3.0.CR1.jar:5.3.0.CR1]
        at org.jbpm.task.service.TaskServiceSession.addGroup(TaskServiceSession.java:101) [jbpm-human-task-5.3.0.CR1.jar:5.3.0.CR1]
        at com.example.my.jbpm.utils.jbpm.JbpmApiUtils.startHumanTaskService(JbpmApiUtils.java:149) [classes:]
        at com.example.my.jbpm.utils.jbpm.JbpmApiUtils.initEngine(JbpmApiUtils.java:244) [classes:]
        at com.example.my.jbpm.MyJbpmServletContextListener.contextInitialized(MyJbpmServletContextListener.java:19) [classes:]
        at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
        at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_31]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_31]
        at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]
Caused by: javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: 
  [org.jbpm.task.Group#guest]
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1359) [hibernate-entitymanager-3.6.9.Final.jar:3.6.9.Final]
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1315) [hibernate-entitymanager-3.6.9.Final.jar:3.6.9.Final]
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1321) [hibernate-entitymanager-3.6.9.Final.jar:3.6.9.Final]
        at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:843) [hibernate-entitymanager-3.6.9.Final.jar:3.6.9.Final]
        at org.jbpm.task.service.persistence.TaskPersistenceManager.saveEntity(TaskPersistenceManager.java:200) [jbpm-human-task-5.3.0.CR1.jar:5.3.0.CR1]
        at org.jbpm.task.service.TaskServiceSession$14.doOperation(TaskServiceSession.java:870) [jbpm-human-task-5.3.0.CR1.jar:5.3.0.CR1]
        at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:890) [jbpm-human-task-5.3.0.CR1.jar:5.3.0.CR1]
        ... 13 more



Is that true that "guest" group already registered in jBPM? How can I check is currently inserting group persisted or not?

Thank you for any help. Have a good day!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/762488#762488]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121001/56b4e886/attachment.html 


More information about the jboss-user mailing list