0 Replies Latest reply on Jun 9, 2010 12:30 PM by dand9959

    Multiple persistence-units causes deployment failure

      I have two persistence units defined in my persistence.xml file (located in META-INF of my project). When I deploy the project .ear file in JBoss 4.2.2 I  get the following error:

       

      [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=serverapp.jar
      java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager com.enfora.reportcontrol.entity.ETLFacade.entityManager :EMPTY STRING unitName and there is more than one scoped persistence unit
          at org.jboss.injection.PersistenceContextHandler.handleFieldAnnotations(PersistenceContextHandler.java:182)
          at org.jboss.injection.InjectionUtil.processFieldAnnotations(InjectionUtil.java:137)
          at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:174)
          at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:358)

         ....

      --- MBeans waiting for other MBeans ---
      ObjectName: jboss.j2ee:service=EJB3,module=serverapp.jar
        State: FAILED
        Reason: java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager com.enfora.reportcontrol.entity.ETLFacade.entityManager :EMPTY STRING unitName and there is more than one scoped persistence unit

       

      ObjectName: jboss.web.deployment:war=webui.war,id=1634829504
        State: FAILED
        Reason: org.jboss.deployment.DeploymentException: URL file:/C:/jboss-4.2.2.GA/server/default/tmp/deploy/tmp5063312647954569252provisioner.ear-contents/webui-exp.war/ deployment failed

       

      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.web.deployment:war=webui.war,id=1634829504
        State: FAILED
        Reason: org.jboss.deployment.DeploymentException: URL file:/C:/jboss-4.2.2.GA/server/default/tmp/deploy/tmp5063312647954569252provisioner.ear-contents/webui-exp.war/ deployment failed

       

      ObjectName: jboss.j2ee:service=EJB3,module=serverapp.jar
        State: FAILED
        Reason: java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager com.enfora.reportcontrol.entity.ETLFacade.entityManager :EMPTY STRING unitName and there is more than one scoped persistence unit

      ...

       

      Here is the persistence.xml file:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">

       

      <persistence-unit name="prvsnr/persistence" transaction-type="JTA">

              <jta-data-source>java:/prvsnr/datasource</jta-data-source>
         </persistence-unit>

       

          <persistence-unit name="reportControl/persistence" transaction-type="JTA">
              <jta-data-source>java:comp/env/reportControl/reportsdatasource</jta-data-source>
         </persistence-unit>

       

      </persistence>

       

      And, in the entity facades, I annotate accordingly:

       

      @PersistenceContext(unitName = "reportControl/persistence", type=PersistenceContextType.TRANSACTION)
          protected EntityManager entityManager;

       

      The data source files are all seemingly correct (*-ds.xml) as they connect to the databases appropriately.

       

      It seems that we only have problem with those entities that use the SECOND persistence unit define. Those that refer to the first unit behave okay. (Verified by removing the 2nd p-unit definition from the peristence.xml file, recompiling and redeploying without error.)

       

      I simply can't find an reason why this is happening.

       

      Regards,

      Dan