0 Replies Latest reply on Oct 2, 2013 2:13 AM by Al Koch

    Can't "integrate" jBPM 5.4 into a Maven web app

    Al Koch Newbie

      Hello,

       

      I have been having trouble getting "jBPM integrated into a web app" while using Eclipse (Kepler).  As a test I am simply trying to replicate the code found in the jBPM Full Installer's evaluation sample into the template code produced by a Maven JavaEE6 Archetype.  I have noted my steps below so that the problem can be easily reproduced.

       

      1) Add to the JBoss standalone.xml:

      <datasource jndi-name="java:jboss/jdbc/jbpm-ds" pool-name="jBPMDS" enabled="true" use-java-context="true">

          <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>

          <driver>h2</driver>

          <security>

              <user-name>sa</user-name>

              <password>sa</password>

          </security>

      </datasource>

       

      2) JBoss Central > Maven Project > filter on "javaee6" (to create the "myservlet" Project):

          Archetype = jboss-javaee6-webapp

          Accept all defaults

       

      3) Set src\main\resources\META-INF\persistencet.xml to contain:

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

      <persistence version="2.0"

         xmlns="http://java.sun.com/xml/ns/persistence" 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_2_0.xsd">

         <persistence-unit name="primary">

            <!-- If you are running in a production environment, add a managed

               data source, the example data source is just for proofs of concept! -->

            <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>

            <properties>

               <!-- Properties for Hibernate -->

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

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

            </properties>

         </persistence-unit>

      </persistence>

       

      4) Add a jBPM Runtime by pointing at the \runtime folder from the jBPM Full Installer.

       

      5) Select the jBPM Perspective, right click the myservlet Project > Convert to jBPM Project.

       

      6) Add to the Deployment Assembly the Java Build Path Entries | jBPM Library.

       

      7) In src\main\java\com\mycompany\mywebapp\controller add to (arbitrarily chosen) MemberRegistration.java (which was automatically created as part of the Project) the following which comes from the evaluation sample code:

      import java.util.HashMap;

      import java.util.Map;

       

      import org.drools.KnowledgeBase;

      import org.drools.builder.KnowledgeBuilder;

      import org.drools.builder.KnowledgeBuilderFactory;

      import org.drools.builder.ResourceType;

      import org.drools.io.ResourceFactory;

      import org.drools.logger.KnowledgeRuntimeLogger;

      import org.drools.logger.KnowledgeRuntimeLoggerFactory;

      import org.drools.runtime.StatefulKnowledgeSession;

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

       

      8) In this same module, in register() add the following which also comes from the evaluation sample code:

      try {

          // load up the knowledge base

          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

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

          KnowledgeBase kbase = kbuilder.newKnowledgeBase();

       

          StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

          HornetQHTWorkItemHandler humanTaskHandler = new HornetQHTWorkItemHandler(ksession);

          humanTaskHandler.setIpAddress("127.0.0.1");

          humanTaskHandler.setPort(5153);

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

       

          KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);

          // start a new process instance

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

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

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

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

          System.out.println("Process started ...");

          logger.close();

          } catch (Throwable t) {

          t.printStackTrace();

      }

       

      Upon deploying along with the six jBPM WARs we get the error:

      Caused by: java.lang.IllegalArgumentException: JBAS011470: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment "myservlet.war".  Either change the application to have only one persistence unit definition or specify the unitName for each reference to a persistence unit.

       

      I have attached the server log.

       

      Can someone explain what this error means and how to eliminate it?

       

      Thank you.

      Al