0 Replies Latest reply on Apr 15, 2013 8:16 AM by Jonathan Albornoz

    Task Server Problem

    Jonathan Albornoz Newbie

      Hi, i have a problem with my java application with jboss 7.0.2, jbpm 5.3 and oracle.

      i run my application and not have problem, but in a few minuts, the server task is blocked, and the log told me that can´t retrieve task.

       

      import javax.persistence.EntityManagerFactory;

      import javax.persistence.Persistence;

      import org.drools.SystemEventListenerFactory;

      import org.jbpm.task.service.TaskService;

      import org.jbpm.task.service.TaskServiceSession;

      import org.jbpm.task.service.mina.MinaTaskServer;

       

      public class levantarServidorTareas {

       

      public static void main(String[] args) {

      try {

                                    EntityManagerFactory emf = Persistence

                                                        .createEntityManagerFactory("org.jbpm.task");

                                    TaskService taskService = new TaskService(emf,

                                                        SystemEventListenerFactory.getSystemEventListener());

                                    TaskServiceSession ts = taskService.createSession();

                                    MinaTaskServer server = new MinaTaskServer(taskService);

                                    Thread thread = new Thread(server);

                                    thread.start();

                                    System.out

                                                        .println("Servidor de Tareas se inició Correctamente...!!");  //The server task start correctly

                          } catch (Exception e) {

       

                                    System.out.println("Servidor de Tareas no se pudo Iniciar...!!"); //The server task is not correctly

                          }

      }

      }

       

       

       

       

      THIS IS MY CLASE JBPM ASSOCIATED TO MY APPLICATION

       

      Clase Jbpm

      package cl.mop.ryc.bpm.bo;

       

       

      import java.util.HashMap;

      import java.util.Map;

      import java.util.Properties;

       

       

      import javax.persistence.EntityManagerFactory;

      import javax.persistence.Persistence;

       

       

      import org.drools.KnowledgeBaseFactory;

      import org.drools.base.MapGlobalResolver;

      import org.drools.builder.KnowledgeBuilder;

      import org.drools.builder.KnowledgeBuilderFactory;

      import org.drools.builder.ResourceType;

      import org.drools.io.ResourceFactory;

      import org.drools.persistence.jpa.JPAKnowledgeService;

      import org.drools.runtime.Environment;

      import org.drools.runtime.EnvironmentName;

      import org.drools.runtime.KnowledgeSessionConfiguration;

      import org.drools.runtime.StatefulKnowledgeSession;

      import org.drools.runtime.process.ProcessInstance;

      import org.jbpm.process.audit.JPAWorkingMemoryDbLogger;

      import org.jbpm.process.workitem.wsht.MinaHTWorkItemHandler;

       

       

      import bitronix.tm.TransactionManagerServices;

       

       

      public class ClasesJbpm {

       

       

                public EntityManagerFactory emf;

                public Environment env;

                public StatefulKnowledgeSession ksession;

                public MinaHTWorkItemHandler hornetQHTWorkItemHandler;

                public JPAWorkingMemoryDbLogger logger;

                public org.jbpm.task.TaskService client;

       

       

                public void persistenciaSesion() {

                          emf = Persistence

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

                          env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          Properties properties = new Properties();

                          properties

                                              .put("drools.processInstanceManagerFactory",

                                                                  "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                          properties.put("drools.processSignalManagerFactory",

                                              "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                          KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                                              .newKnowledgeSessionConfiguration(properties);

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

                                              .newKnowledgeBuilder();

                          kbuilder.add(ResourceFactory.newClassPathResource("HumanTask.bpmn"),

                                              ResourceType.BPMN2);

                          ksession = JPAKnowledgeService.newStatefulKnowledgeSession(

                                              kbuilder.newKnowledgeBase(), config, env);

                }

       

       

                public void persistenciaSesionLoad(int id) {

                          emf = Persistence

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

                          env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          Properties properties = new Properties();

                          properties

                                              .put("drools.processInstanceManagerFactory",

                                                                  "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                          properties.put("drools.processSignalManagerFactory",

                                              "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                          KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                                              .newKnowledgeSessionConfiguration(properties);

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

                                              .newKnowledgeBuilder();

                          kbuilder.add(ResourceFactory.newClassPathResource("HumanTask.bpmn"),

                                              ResourceType.BPMN2);

                          ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id,

                                              kbuilder.newKnowledgeBase(), config, env);

                }

       

       

                public void persistenciaSesionConcesion() {

                          emf = Persistence

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

                          env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          Properties properties = new Properties();

                          properties

                                              .put("drools.processInstanceManagerFactory",

                                                                  "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                          properties.put("drools.processSignalManagerFactory",

                                              "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                          KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                                              .newKnowledgeSessionConfiguration(properties);

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

                                              .newKnowledgeBuilder();

                          kbuilder.add(ResourceFactory.newClassPathResource("Concesiones.bpmn"),

                                              ResourceType.BPMN2);

                          ksession = JPAKnowledgeService.newStatefulKnowledgeSession(

                                              kbuilder.newKnowledgeBase(), config, env);

                }

       

       

                public void persistenciaSesionTransparencia() {

                          emf = Persistence

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

                          env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          Properties properties = new Properties();

                          properties

                                              .put("drools.processInstanceManagerFactory",

                                                                  "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                          properties.put("drools.processSignalManagerFactory",

                                              "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                          KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                                              .newKnowledgeSessionConfiguration(properties);

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

                                              .newKnowledgeBuilder();

                          kbuilder.add(

                                              ResourceFactory.newClassPathResource("Transparencia.bpmn"),

                                              ResourceType.BPMN2);

                          ksession = JPAKnowledgeService.newStatefulKnowledgeSession(

                                              kbuilder.newKnowledgeBase(), config, env);

                }

       

       

                public void persistenciaSesionActoresRelevantes() {

                          emf = Persistence

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

                          env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          Properties properties = new Properties();

                          properties

                                              .put("drools.processInstanceManagerFactory",

                                                                  "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                          properties.put("drools.processSignalManagerFactory",

                                              "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                          KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                                              .newKnowledgeSessionConfiguration(properties);

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

                                              .newKnowledgeBuilder();

                          kbuilder.add(

                                              ResourceFactory.newClassPathResource("ActoresRelevantes.bpmn"),

                                              ResourceType.BPMN2);

                          ksession = JPAKnowledgeService.newStatefulKnowledgeSession(

                                              kbuilder.newKnowledgeBase(), config, env);

                }

       

       

                public void persistenciaSesionLoadActoresRelevantes(int id) {

                          emf = Persistence

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

                          env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          Properties properties = new Properties();

                          properties

                                              .put("drools.processInstanceManagerFactory",

                                                                  "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                          properties.put("drools.processSignalManagerFactory",

                                              "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                          KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                                              .newKnowledgeSessionConfiguration(properties);

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

                                              .newKnowledgeBuilder();

                          kbuilder.add(

                                              ResourceFactory.newClassPathResource("ActoresRelevantes.bpmn"),

                                              ResourceType.BPMN2);

                          ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id,

                                              kbuilder.newKnowledgeBase(), config, env);

                }

       

       

                public void persistenciaSesionLoadTransparencia(int id) {

                          emf = Persistence

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

                          env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          Properties properties = new Properties();

                          properties

                                              .put("drools.processInstanceManagerFactory",

                                                                  "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                          properties.put("drools.processSignalManagerFactory",

                                              "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                          KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                                              .newKnowledgeSessionConfiguration(properties);

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

                                              .newKnowledgeBuilder();

                          kbuilder.add(

                                              ResourceFactory.newClassPathResource("Transparencia.bpmn"),

                                              ResourceType.BPMN2);

                          ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id,

                                              kbuilder.newKnowledgeBase(), config, env);

                }

       

       

                public void persistenciaSesionLoadConcesion(int id) {

                          emf = Persistence

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

                          env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          Properties properties = new Properties();

                          properties

                                              .put("drools.processInstanceManagerFactory",

                                                                  "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                          properties.put("drools.processSignalManagerFactory",

                                              "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                          KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                                              .newKnowledgeSessionConfiguration(properties);

                          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

                                              .newKnowledgeBuilder();

                          kbuilder.add(ResourceFactory.newClassPathResource("Concesiones.bpmn"),

                                              ResourceType.BPMN2);

                          ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id,

                                              kbuilder.newKnowledgeBase(), config, env);

                }

       

       

                public void registrarWorkItemHandler() {

                          hornetQHTWorkItemHandler = new MinaHTWorkItemHandler(ksession);

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

                                              hornetQHTWorkItemHandler);

                          hornetQHTWorkItemHandler.setIpAddress("127.0.0.1");

                          hornetQHTWorkItemHandler.setPort(9123);

                          hornetQHTWorkItemHandler.connect();

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

                                              hornetQHTWorkItemHandler);

                }

       

       

                public void registrarLogger() {

                          logger = new JPAWorkingMemoryDbLogger(ksession);

                }

       

       

                public void instanciarProceso(String idProceso, Map<String, Object> params) {

                          ksession.startProcess(idProceso, params);

                }

       

       

                public ProcessInstance instanciarProceso(String idProceso) {

                          ProcessInstance pi = ksession.startProcess(idProceso);

                          return pi;

       

       

                }

       

       

                public ProcessInstance instanciarProcesoParam(String idProceso,

                                    HashMap<String, Object> param) {

                          ProcessInstance pi = ksession.startProcess(idProceso, param);

                          return pi;

       

       

                }

       

       

                public void obtenerCliente() {

                          client = hornetQHTWorkItemHandler.getClient();

                }

       

       

                public void cerrarConexion() {

                          try {

                                    client.disconnect();

                                    hornetQHTWorkItemHandler.dispose();

                          } catch (Exception e) {

                                    e.printStackTrace();

                          }

                          logger.dispose();

                          ksession.dispose();

                }

      }


       

      AND FINALLY MY PERSISTENCE.XML ASSOCIATED TO THE APP

       

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

      <persistence version="1.0"

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

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

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

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

       

       

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

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

              <mapping-file>META-INF/JBPMorm.xml</mapping-file>

              <mapping-file>META-INF/ProcessInstanceInfo.hbm.xml</mapping-file>

              <class>org.drools.persistence.info.SessionInfo</class>

              <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>

              <class>org.drools.persistence.info.WorkItemInfo</class>

              <class>org.jbpm.process.audit.ProcessInstanceLog</class>

                    <class>org.jbpm.process.audit.NodeInstanceLog</class>

                    <class>org.jbpm.process.audit.VariableInstanceLog</class>

              <properties>

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

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

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

                  <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.16.1.35:1521:prodbeta" />

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

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

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

              </properties>       

          </persistence-unit>

         

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

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

                <mapping-file>META-INF/Taskorm.xml</mapping-file>

          <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.default_schema" value="jbpm5"/>

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

            <property name="hibernate.connection.url" value="jdbc:oracle:thin:@172.16.1.35:1521:prodbeta" />

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

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

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

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

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

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

          </properties>

        </persistence-unit>

      </persistence>