"JBAS011470: Persistence unitName was not specified and there are 2 persistence unit definitions ..." in JBoss EAP

Solution Verified - Updated -

Issue

  • Multiple persistence units are defined in a single persistence.xml included in an EAR
  • At deployment of the EAR, the following exception is raised:
JBAS011470: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment "test.ear".  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.processField(JPAAnnotationProcessor.java:167)
        at org.jboss.as.jpa.processor.JPAAnnotationProcessor.processPersistenceAnnotations(JPAAnnotationProcessor.java:134)
        at org.jboss.as.jpa.processor.JPAAnnotationProcessor.deploy(JPAAnnotationProcessor.java:96)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159)
        ...

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7
    • 6
  • Hibernate
    • 5
    • 4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content