0 Replies Latest reply on Oct 8, 2013 12:23 AM by Al Koch

    Addition of jBPM 5.4 runtime to Jave EE web app triggers persistence.xml "duplicate" error

    Al Koch Newbie

      Hello,

       

      I am trying to integrate jBPM 5.4 into an Eclipse (Kepler) Maven generated J2EE web app Project and am getting the following error:

       

      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 am simply trying to replicate the jBPM Full Installer's evaluation sample in a J2EE web app.  Here are the steps that are easy to reproduce:

       

      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\persistence.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="myapp">

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

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

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

            <jta-data-source>java:jboss/jdbc/jbpm-ds</jta-data-source>

            <properties>

               <!-- Properties for Hibernate -->

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

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

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

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

            </properties>

         </persistence-unit>

      </persistence>

       

      This can be deployed to JBoss with no problems.

       

      However, if we now add some jBPM imports and the jBPM runtime to resolve those imports we will trigger the error above.  Here are the steps:

       

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

       

      5) To resolve the errors that are generated by the addition of these imports, add to the Java Build Path the 25 .jars in the Full Installer's runtime folder.

       

      6) Add to the Project's Deployment Assembly the "Java Build Path Entries" (to deploy those 25 .jar files).

       

      If we now try to deploy we get the error shown above.

       

      My original persistence.xml file works but once I include the 25 jBPM 5.4 .jar files we get the error.

       

      Is another persistence.xml being included along with the 25 jBPM .jar files?

       

      How is jBPM supposed to be integrated into a J2EE web app?

       

      Thank you.