0 Replies Latest reply on Jun 1, 2015 4:17 AM by chiaan Hung

    How to use two persistence units on eap6.3?

    chiaan Hung Novice

      Now I use deployservice to dynamically add or change bpmn file at runtime. An error occurs when I have two persistence units in the same persistence.xml. The error is shown as follows:

       

      15:51:14,076 INFO  [org.jboss.as.jpa] (MSC service thread 1-10) JBAS011401: Read persistence.xml for org.jbpm.domain
      15:51:14,076 INFO  [org.jboss.as.jpa] (MSC service thread 1-10) JBAS011401: Read persistence.xml for jpatest
      15:51:14,085 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.unit."rewards-basic-6.2.0-SNAPSHOT.war".DEPENDENCIES: org.jboss.msc.service.StartException in service jboss.deployment.unit."rewards-basic-6.2.0-SNAPSHOT.war".DEPENDENCIES: JBAS018733: Failed to process phase DEPENDENCIES of deployment "rewards-basic-6.2.0-SNAPSHOT.war"
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [jboss-as-server-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
          at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
      Caused by: java.lang.IllegalArgumentException: JBAS011470: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment "rewards-basic-6.2.0-SNAPSHOT.war".  Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit.
          at org.jboss.as.jpa.container.PersistenceUnitSearch.ambiguousPUError(PersistenceUnitSearch.java:171)
          at org.jboss.as.jpa.container.PersistenceUnitSearch.findWithinDeployment(PersistenceUnitSearch.java:151)
          at org.jboss.as.jpa.container.PersistenceUnitSearch.findPersistenceUnitSupplier(PersistenceUnitSearch.java:74)
          at org.jboss.as.jpa.container.PersistenceUnitSearch.resolvePersistenceUnitSupplier(PersistenceUnitSearch.java:63)
          at org.jboss.as.jpa.processor.JPAAnnotationProcessor.getPersistenceUnit(JPAAnnotationProcessor.java:358)
          at org.jboss.as.jpa.processor.JPAAnnotationProcessor.getBindingSource(JPAAnnotationProcessor.java:289)
          at org.jboss.as.jpa.processor.JPAAnnotationProcessor.processMethod(JPAAnnotationProcessor.java:202)
          at org.jboss.as.jpa.processor.JPAAnnotationProcessor.processPersistenceAnnotations(JPAAnnotationProcessor.java:139)
          at org.jboss.as.jpa.processor.JPAAnnotationProcessor.deploy(JPAAnnotationProcessor.java:110)
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [jboss-as-server-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
          ... 5 more
      
      
      
      

       

      I think I already specify persistence unit name in kie-deployment-descriptor.xml. Everything works fine before I add second persistence unit. The following is my kie-deployment-descriptor.xml file:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <deployment-descriptor xsi:schemaLocation="http://www.jboss.org/jbpm deployment-descriptor.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <persistence-unit>org.jbpm.domain</persistence-unit>
          <audit-persistence-unit>org.jbpm.domain</audit-persistence-unit>
          <audit-mode>JPA</audit-mode>
          <persistence-mode>JPA</persistence-mode>
          <runtime-strategy>PER_REQUEST</runtime-strategy>
          <marshalling-strategies/>
      
          <work-item-handlers>
          
              <work-item-handler>
                  <resolver>mvel</resolver>
                  <identifier>new handler.TestWorkItemHandler1()</identifier>
                  <parameters/>
                  <name>xx</name>
              </work-item-handler>
          </work-item-handlers>
          <environment-entries/>
          <configurations/>
          <required-roles>
              <required-role>view:kiemgmt</required-role>
          </required-roles>
      </deployment-descriptor>
      
      
      
      

       

       

      The error log is attached.THX! ( PS.  now I use jbpm6.2.0.Final and jboss-eap-6.3)