7 Replies Latest reply on Sep 21, 2011 2:05 AM by Rajan Bansal

    Running humantasks with HumanTaskService(Running in JBoss)

    Rajan Bansal Newbie

      Hi all,

       

      I successfully starts the Human Task Service of jBPM5.1 in JBoss by modifing the Persistence.xml:

       

      <?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" transaction-type="JTA">

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

      <jta-data-source>java:/testDS1</jta-data-source>  

      <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.Oracle10gDialect"/>

            <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>

           <!-- <property name="hibernate.connection.url" value="jdbc:oracle:thin:@172.25.8.251:xxxx:xxx" />

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

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

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

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

        <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

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

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

          </properties>

        </persistence-unit>

      </persistence>

       

      and by making JTA data-source as under:

       

      <datasources>

        <xa-datasource>

          <jndi-name>testDS1</jndi-name>

          <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>

          <xa-datasource-property name="URL">jdbc:oracle:thin:@xxx.xx.x.xxx:1521:xxxxx</xa-datasource-property>

         <user-name>jbpm5</user-name>

      <password>lupin</password>   

      </xa-datasource>

       

      </datasources>

       

       

      By these modifications and placing the necessary files, I able to start the human task service via JBoss :

       

      Now I want my jbpm task run using this service as under:

       

                          // load up the knowledge base

                            KnowledgeBase kbase = readKnowledgeBase();

                            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                            WSHumanTaskHandler objWSHuman= new WSHumanTaskHandler();

                            objWSHuman.setConnection("127.0.0.1", 9123);

             

                       ksession.getWorkItemManager().registerWorkItemHandler("Human Task",objWSHuman);

                       // start a new process instance

                       Map<String, Object> params = new HashMap<String, Object>();

                       params.put("employee", "rajan");

                       params.put("reason", "Yearly performance evaluation");

                       ksession.startProcess("com.sample.evaluation", params);

                       System.out.println("Thats itt..");

       

      But on the JBoss console it gives the following error:

       

      19:42:50,382 INFO  [LoggingFilter] CREATED

      19:42:50,382 INFO  [LoggingFilter] OPENED

      19:42:50,428 INFO  [LoggingFilter] RECEIVED: HeapBuffer[pos=0 lim=339 cap=2048: 00 00 01 4F AC ED 00 05 73 72 01 00 1D 6F 72 67...]

      19:42:50,428 INFO  [LoggingFilter] RECEIVED: HeapBuffer[pos=0 lim=336 cap=2048: 00 00 01 4C AC ED 00 05 73 72 01 00 1D 6F 72 67...]

      19:42:50,428 INFO  [LoggingFilter] RECEIVED: HeapBuffer[pos=0 lim=337 cap=1024: 00 00 01 4D AC ED 00 05 73 72 01 00 1D 6F 72 67...]

      19:42:50,444 INFO  [LoggingFilter] RECEIVED: HeapBuffer[pos=0 lim=654 cap=1024: 00 00 02 8A AC ED 00 05 73 72 01 00 1D 6F 72 67...]

      19:42:50,444 ERROR [STDERR] java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

      19:42:50,444 ERROR [STDERR]     at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)

      19:42:50,444 ERROR [STDERR]     at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:811)

      19:42:50,444 ERROR [STDERR]     at org.jbpm.task.service.TaskServiceSession.addTask(TaskServiceSession.java:134)

      19:42:50,444 ERROR [STDERR]     at org.jbpm.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:109)

      19:42:50,444 ERROR [STDERR]     at org.jbpm.task.service.mina.MinaTaskServerHandler.messageReceived(MinaTaskServerHandler.java:41)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:713)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:375)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:229)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:176)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969)

      19:42:50,444 ERROR [STDERR]     at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)

      19:42:50,444 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

      19:42:50,444 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

      19:42:50,444 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:662)

      19:42:50,460 INFO  [LoggingFilter] SENT: HeapBuffer[pos=0 lim=2292 cap=4096: 00 00 08 F0 AC ED 00 05 73 72 01 00 1D 6F 72 67...]

      19:42:50,460 INFO  [LoggingFilter] SENT: HeapBuffer[pos=0 lim=0 cap=0: empty]

      19:43:02,453 INFO  [LoggingFilter] IDLE

      19:43:13,448 INFO  [LoggingFilter] IDLE

      19:43:25,442 INFO  [LoggingFilter] IDLE

       

       

      no idea on this:

       

      Please help!!!

        • 1. Re: Running humantasks with HumanTaskService(Running in JBoss)
          Rajan Bansal Newbie

          Not able to solve problem till yet.

           

          Help!!

          • 2. Re: Running humantasks with HumanTaskService(Running in JBoss)
            Mauricio Salatino Master

            OK, so did you deploy the datasource inside JBoss correctly?

            <jta-data-source>java:/testDS1</jta-data-source>

             

            You need to be sure that you have everything in place, in order to run it. We are working hard to get those integrations pieces aligned. Cheers

            • 3. Re: Running humantasks with HumanTaskService(Running in JBoss)
              Rajan Bansal Newbie

              Hi ,

               

              Actually I want to run the stand-alone service "HumanTaskService" via Jboss but not by ant.

              And in this I want my Oracle database is used for all the transactions instead of its own db.

               

              So I make the necessary changes in the jbpm-human-task-5.1.0.Final.jar:

               

              I changed the Persistence.xml as I used the JTA data-source for it:

               

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

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

                   <jta-data-source>java:/testDS1</jta-data-source>  

                   <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>

               

               

              And my datasource is:

              <datasources>

                <xa-datasource>

                  <jndi-name>testDS1</jndi-name>

                  <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>

                  <xa-datasource-property name="URL">jdbc:oracle:thin:@172.xx.x.251:1521:lupin</xa-datasource-property>

                 <user-name>xxxxx</user-name>

                <password>xxxxx</password>   

                </xa-datasource>

              </datasources>

              It is successfully deployed in the jboss.

               

              But when I want to start "humantaskservice" code in the JBoss then it gives the following error when I am trying to add users:

               

              public void startTaskService() {

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

                  

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

                      TaskServiceSession taskSession = taskService.createSession();

                     

                      // Add users

                      Map vars = new HashMap();

                      Reader reader = new InputStreamReader( StartTaskService.class.getResourceAsStream( "LoadUsers.mvel" ) );    

                      Map<String, User> users = ( Map<String, User> ) eval( reader, vars );  

                      for ( User user : users.values() ) {

                          taskSession.addUser( user );

                      }          

                     

                      reader = new InputStreamReader( StartTaskService.class.getResourceAsStream( "LoadGroups.mvel" ) );     

                      Map<String, Group> groups = ( Map<String, Group> ) eval( reader, vars );    

                      for ( Group group : groups.values() ) {

                          taskSession.addGroup(group);

                      }

                     

                      // start server

                      MinaTaskServer server = new MinaTaskServer(taskService);

                      Thread thread = new Thread(server);

                      thread.start();

                      taskSession.dispose();

                      System.out.println("Task service started correctly !");

                      System.out.println("Task service running ...");

                  }

               

              the error is:

               

              10:23:18,772 INFO  [SchemaExport] Running hbm2ddl schema export

              10:23:18,772 INFO  [SchemaExport] exporting generated schema to database

              10:23:20,895 INFO  [SchemaExport] schema export complete

              10:23:20,895 INFO  [NamingHelper] JNDI InitialContext properties:{}

              10:23:21,238 INFO  [STDOUT] Hibernate: select task0_.id as col_0_0_, deadline1_.id as col_1_0_, deadline1_.deadline_date as col_2_0_ from Task task0_, Deadline deadline1_ where (deadline1_.id in (select startdeadl2_.id from Deadline startdeadl2_ where task0_.id=startdeadl2_.Deadlines_StartDeadLine_Id) or deadline1_.id in (select enddeadlin3_.id from Deadline enddeadlin3_ where task0_.id=enddeadlin3_.Deadlines_EndDeadLine_Id)) and deadline1_.escalated=0 order by deadline1_.deadline_date

              10:23:21,659 INFO  [STDOUT] Adding userss........

              10:23:21,691 ERROR [[springmvc]] Servlet.service() for servlet springmvc threw exception

              java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

                  at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)

                  at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:811)

                  at org.jbpm.task.service.TaskServiceSession.persistInTransaction(TaskServiceSession.java:786)

                  at org.jbpm.task.service.TaskServiceSession.addUser(TaskServiceSession.java:69)

                  at com.service.StartTaskService.startTaskService(StartTaskService.java:54)

                  at com.service.HumanTaskService.startHumanTask(HumanTaskService.java:17)

                  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:597)

                  at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)

                  at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)

                  at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)

                  at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)

                  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)

                  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)

                  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)

                  at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)

                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

                  at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

                  at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

                  at java.lang.Thread.run(Thread.java:662)

              10:25:21,982 INFO  [ServletContextListener] Welcome to Seam 2.1.0.SP1

              10:25:30,353 WARN  [Component] Component class should be serializable: org.jboss.

               

               

              please tell me what to do.

              • 4. Re: Running humantasks with HumanTaskService(Running in JBoss)
                Rajan Bansal Newbie

                As in the my first post I told that, I successfully started the ServiceHumanTask, but my Task is not running using that service.

                 

                I figure out that it may be the case that I was not added the users when starting of the service.

                So now I tried to add users into the service during start-up. But got the error as shown in the above post.

                 

                It told that A JTA EntityManager cannot use getTransaction() but I dont know where this getTransaction() method is being called when I am adding users and groups.

                 

                i dont know much about the JTA's

                 

                So please help me out..

                 

                Regards.

                • 5. Re: Running humantasks with HumanTaskService(Running in JBoss)
                  Miljenko Norsic Newbie

                  Hi Rajan,

                   

                  according to Hibernate docs, I suspect the problem might be because you are not using user transaction (java:comp/UserTransaction). Please see the following topic: https://forum.hibernate.org/viewtopic.php?t=970727&view=next&sid=e94d5d4e467a4eed7d35cfe6869dd8e0.

                   

                  Try the following:

                  UserTransaction ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");

                  ut.begin();

                  //....add users and groups

                  ut.commit();

                   

                  Thanks,

                  Miljenko

                  1 of 1 people found this helpful
                  • 6. Re: Running humantasks with HumanTaskService(Running in JBoss)
                    Maciej Swiderski Master

                    I think that currently (5.1) TaskService does not support JTA transactions, there were number of posts on the forum discussing that and even some guys have made some implementation to make that working.

                    You can change your persistence configuration to be non JTA, that includes transaction-type attribute of persistence unit and data source tag. Transaction type should be resource local and data source should be non-jta-data-source. That should make task service available and work properly.

                     

                    HTH

                    1 of 1 people found this helpful
                    • 7. Re: Running humantasks with HumanTaskService(Running in JBoss)
                      Rajan Bansal Newbie

                      Thanks Maciej

                       

                      I have now successfully started the HumanTaskService in JBoss, and able to run processes with (user task) in that service.

                       

                      I also signal the "user task" via my own code.

                       

                      Regards.