1 2 Previous Next 16 Replies Latest reply on Sep 6, 2011 1:01 AM by kishoret

    Instantiating a process in JBPM5

    imran.h

      I have deployed jbpm5 in my web container. I am trying to emulate the example given here to create a process instance of the Evaluate.bpmn process:

      http://docs.jboss.org/jbpm/v5.1/userguide/ch05.html#d0e1532

       

      But whenever I run this code I get an error: java.lang.IllegalArgumentException: Unknown process ID: Evaluation

       

      My code snippet is:

       

           KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

            kbuilder.add(ResourceFactory.newClassPathResource("Evaluation.bpmn"), ResourceType.BPMN2);

            KnowledgeBase kbase = kbuilder.newKnowledgeBase();

           

            JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);

           

            ProcessInstance processInstance = ksession.startProcess("Evaluation");

       

       

      The error is thrown when at the last line. I have not done anything to configure the database so most likely thats the problem. Although I dont think the guide explicitly this.

       

      I wish to just get the process execution working. I dont need the console. My questions are:

       

      1) I tried locating the hibernate config file in the jars but didnt find them. Can some one point me to it.

       

      2) Since my project already uses hibernate, is it safe to assume all I need to do is incorporate the jbpm hibernate files into it to make it work?

       

      Thanks

        • 1. Re: Instantiating a process in JBPM5
          salaboy21

          The error is pretty clear:

           

          Unknown process ID: Evaluation

           

           

          Check inside the Evaluation.bpmn file and look inside the process tag (<process id="....">) for the id attribute.

          When you want to start a process you should use the id that is specified inside that attribute.

          If that works we can see what is missing in hibernate, because you will get a different error.

          Cheers

          • 2. Re: Instantiating a process in JBPM5
            imran.h

            Right. that worked. I'm now getting:

            java.lang.ClassNotFoundException: javax.persistence.EntityManager

             

            My project is a non-jpa hibernate project and doesnt use an Entity Manager. Can I manually add all the jbpm entities to my hibernate config file to get around this?

            Thanks for your help.

            • 3. Re: Instantiating a process in JBPM5
              swiderski.maciej

              Error you're getting is cause by usage od JPAWorkingMemoryDbLogger, since as its name implies it relies on JPA and entity manager.

               

              You could try using WorkingMemoryDbLogger instead, this one is based on hibernate directly.

               

              HTH

              • 4. Re: Instantiating a process in JBPM5
                imran.h

                Thank you for your answer.

                I took out the db logger for now.

                 

                I am getting the followin gexception:

                 

                java.lang.IllegalArgumentException: Could not connect task client

                        at org.jbpm.process.workitem.wsht.CommandBasedWSHumanTaskHandler.connect(CommandBasedWSHumanTaskHandler.java:88)

                        at org.jbpm.process.workitem.wsht.CommandBasedWSHumanTaskHandler.executeWorkItem(CommandBasedWSHumanTaskHandler.java:101)

                        at org.drools.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:70)

                        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:105)

                 

                 

                 

                Evaluate.bpmn has manual tasks in it. According to the documentation I must initialize the TaskService as a separate service. The task service itself takes an instance of an EntitymanagerFactory:

                 

                      EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.drools.task");

                      TaskService taskService = new TaskService(emf);

                      MinaTaskServer server = new MinaTaskServer( taskService );

                      Thread thread = new Thread( server );

                      thread.start();

                 

                 

                Is there any way of getting the task service without jpa?

                • 5. Re: Instantiating a process in JBPM5
                  swiderski.maciej

                  Error you are getting is caused because client can't connect to you Task Service, as you mentioned you need first start Task Service.

                   

                  I am afraid there is no way to go around JPA in Task Service, it is directly using JPA.

                   

                  Cheers

                  • 6. Re: Instantiating a process in JBPM5
                    imran.h

                    I'm now setting up jbpm more traditionally through jpa. The aim is to have it embedded in my app. When I try to create my entity manager to instantiate the task service though, I get the following exception:

                     

                    javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] class or package not found

                            at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1092)

                            at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:871)

                            at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:758)

                            at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)

                            at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)

                    Caused by: java.lang.ClassNotFoundException: org.drools.task.query.TaskSummary

                            at java.net.URLClassLoader$1.run(URLClassLoader.java:217)

                            at java.security.AccessController.doPrivileged(Native Method)

                            at java.net.URLClassLoader.findClass(URLClassLoader.java:205)

                            at java.lang.ClassLoader.loadClass(ClassLoader.java:321)

                    Error in named query: SubTasksAssignedAsPotentialOwner

                    org.hibernate.hql.ast.QuerySyntaxException: Unable to locate class [org.drools.task.query.TaskSummary] [select new org.drools.task.query.TaskSummary( t.id, names.text, subjects.text, descriptions.text, t.taskData.status, t.priority, t.ta

                    skData.skipable, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime) from org.jbpm.task.Task t left join t.taskData.createdBy left join t.taskData.actualOwner, org.jbp

                    m.task.I18NText names, org.jbpm.task.I18NText subjects, org.jbpm.task.I18NText descriptions, org.jbpm.task.OrganizationalEntity potentialOwners where t.taskData.parentId = :parentId and potentialOwners.id = :userId and potentialOwners in

                    elements ( t.peopleAssignments.potentialOwners ) and names.language = :language and names in elements( t.names) and ( subjects.language = :language and subjects in elements( t.subjects) or t.subjects.size = 0 ) and ( descriptions.langua

                    ge = :language and descriptions in elements( t.descriptions) or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null]

                            at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)

                            at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)

                            at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)

                            at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:235)

                            at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)

                     

                    The exception is obvious, but I had two questions:

                     

                    1- Which jar has this class and where to I download it. I already have drools core and compiler jars.

                    2- Why do I need this jar. I think I have added everything I need according to the documentation.

                     

                     

                    Thanks in advance for your help.

                    • 7. Re: Instantiating a process in JBPM5
                      salaboy21

                      do you have jbpm-persistence-jpa & jbpm-human-tasks? you need that to persist the task status for long runnning processes.

                      Cheers

                      • 8. Re: Instantiating a process in JBPM5
                        imran.h

                        Yes I have both those jars. Neither of those contain the class TaskSummary. If it helps my code snippet is:

                        LOG.info("starting jbpm");

                              EntityManagerFactory emf = loadPrimaryConfig().buildEntityManagerFactory();//Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");

                              TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());

                              TaskServiceSession taskSession = taskService.createSession();

                         

                         

                        The errors occur when I try to instatitiate the task service:  TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());

                        • 9. Re: Instantiating a process in JBPM5
                          salaboy21

                          I think that's the problem:

                           

                          Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");

                           

                           

                          That's the one for session persistence. you should use org.jbpm.task.

                          TaskSummary is inside jbpm-human-task.jar I've just check it:

                          package org.jbpm.task.query;

                          ...

                          public class TaskSummary

                           

                          and the persistence.xml file looks like:

                          <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

                          <persistence version="1.0"

                                       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence

                                                           http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd

                                                           http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"

                                       xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"

                                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                       xmlns="http://java.sun.com/xml/ns/persistence">

                            <persistence-unit name="org.jbpm.task">

                              <provider>org.hibernate.ejb.HibernatePersistence</provider>

                              <class>org.jbpm.task.Attachment</class>

                              <class>org.jbpm.task.Content</class>

                              <class>org.jbpm.task.BooleanExpression</class>

                              <class>org.jbpm.task.Comment</class>

                              <class>org.jbpm.task.Deadline</class>

                              <class>org.jbpm.task.Comment</class>

                              <class>org.jbpm.task.Deadline</class>

                              <class>org.jbpm.task.Delegation</class>

                              <class>org.jbpm.task.Escalation</class>

                              <class>org.jbpm.task.Group</class>

                              <class>org.jbpm.task.I18NText</class>

                              <class>org.jbpm.task.Notification</class>

                              <class>org.jbpm.task.EmailNotification</class>

                              <class>org.jbpm.task.EmailNotificationHeader</class>

                              <class>org.jbpm.task.PeopleAssignments</class>

                              <class>org.jbpm.task.Reassignment</class>

                              <class>org.jbpm.task.Status</class>

                              <class>org.jbpm.task.Task</class>

                              <class>org.jbpm.task.TaskData</class>

                              <class>org.jbpm.task.SubTasksStrategy</class>

                              <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>

                              <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>

                              <class>org.jbpm.task.User</class>

                              <properties>

                                <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>

                                <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>

                                <property name="hibernate.connection.url" value="jdbc:h2:mem:mydb" />

                                <property name="hibernate.connection.username" value="sa"/>

                                <property name="hibernate.connection.password" value="sasa"/>

                                <property name="hibernate.connection.autocommit" value="false" />

                                <property name="hibernate.max_fetch_depth" value="3"/>

                                <property name="hibernate.hbm2ddl.auto" value="create" />

                                <property name="hibernate.show_sql" value="false" />

                              </properties>

                            </persistence-unit>

                          </persistence>

                           

                          Cheers

                          • 10. Re: Instantiating a process in JBPM5
                            imran.h

                            Thanks for your help, thats worked.

                            • 11. Re: Instantiating a process in JBPM5
                              imran.h

                              I am able to run a process end to end. But I need to eventually persist it for longer running processes and also for persistent tasks. For that I still need to use the "org.jbpm.persistence.jpa" persistence which throws the above exception:

                               

                              Error in named query: SubTasksAssignedAsPotentialOwner

                              org.hibernate.hql.ast.QuerySyntaxException: Unable to locate class [org.drools.task.query.TaskSummary] [select new org.drools.task.query.TaskSummary( t.id, names.text, subjects.text, descriptions.text, t.taskData.status, t.priority, t.taskData.skipable, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime) from org.jbpm.task.Task t left join t.taskData.createdBy left join t.taskData.actualOwner, org.jbpm.task.I18NText names, org.jbpm.task.I18NText subjects, org.jbpm.task.I18NText descriptions, org.jbpm.task.OrganizationalEntity potentialOwners where t.taskData.parentId = :parentId and potentialOwners.id = :userId and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and names.language = :language and names in elements( t.names) and ( subjects.language = :language and subjects in elements( t.subjects) or t.subjects.size = 0 ) and ( descriptions.language = :language and descriptions in elements( t.descriptions) or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null]

                                      at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)

                                      at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)

                                      at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)

                               

                               

                              This is talking about the drools TaskSummary class (org.drools.task.query.TaskSummary) and not the jbpm taskSummary class which, as you pointed out is in jbpm-human-task.jar

                              Please let me know if you need further info. Thanks.

                              • 12. Re: Instantiating a process in JBPM5
                                calca

                                Does the exception has the cause? I mean, could you please copy the full stack?

                                • 13. Re: Instantiating a process in JBPM5
                                  imran.h

                                  In my stderr.log I see this exception:

                                   

                                  ESC[0mjavax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory

                                          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)

                                  Caused by: org.hibernate.HibernateException: Errors in named queries: TasksAssignedAsPotentialOwnerWithGroups, TasksOwned, TasksAssignedAsPotentialOwner, TasksAssignedAsRecipient, TasksAssignedAsTaskStakeholder, UnescalatedDeadlines, TasksAssignedAsExcludedOwner, TasksAssignedAsPotentialOwnerByGroup, GetSubTasksByPa

                                  rentTaskId, TasksAssignedAsTaskInitiator, TasksAssignedAsBusinessAdministrator, SubTasksAssignedAsPotentialOwner

                                          at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:365)

                                          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)

                                          at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)

                                          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)

                                          ... 33 more

                                   

                                   

                                  In my app log I see this exception:

                                   

                                  [REQ:4ABE653B0B118.AC114F2C.267B6495]] Error in named query: SubTasksAssignedAsPotentialOwner

                                  org.hibernate.hql.ast.QuerySyntaxException: Unable to locate class [org.drools.task.query.TaskSummary] [select new org.drools.task.query.TaskSummary( t.id, names.text, subjects.text, descriptions.text, t.taskData.status, t.priority, t.taskData.skipable, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime) from org.jbpm.task.Task t left join t.taskData.createdBy left join t.taskData.actualOwner, org.jbpm.task.I18NText names, org.jbpm.task.I18NText subjects, org.jbpm.task.I18NText descriptions, org.jbpm.task.OrganizationalEntity potentialOwners where t.taskData.parentId = :parentId and potentialOwners.id = :userId and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and names.language = :language and names in elements( t.names) and ( subjects.language = :language and subjects in elements( t.subjects) or t.subjects.size = 0 ) and ( descriptions.language = :language and descriptions in elements( t.descriptions) or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null]

                                          at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)

                                          at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)

                                          at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)

                                          at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:235)

                                          at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)

                                          at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)

                                          at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)

                                          at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)

                                          at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)

                                          at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:402)

                                          at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:352)

                                          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)

                                          at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)

                                          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)

                                   

                                  There is no cause. The app log has a few more exceptions for other queries but the cause for all is the same, no TaskSummary.

                                  • 14. Re: Instantiating a process in JBPM5
                                    imran.h

                                    Found the issue. My code was picking up the orm.xml in the drools jar instead of the jbpm one.

                                    1 2 Previous Next