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

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




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









      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"




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



               <!-- Properties for Hibernate -->

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

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





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



          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 ...");


          } catch (Throwable t) {




      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.