Can a persistence unit packaged inside of an EJB jar be accessible by other jars in EAP ?

Solution Verified - Updated -

Issue

  • The persistence.xml is packaged inside of one jar xxx.jar. When other jar tries to access the persistence unit using
@PersistenceContext (unitName="xxx.jar#MY_Persistence-Unit")

the following errors occur:

java.lang.IllegalArgumentException: JBAS011441: Can't find a persistence unit named xxx.jar#MY_Persistence-Unit at deployment yyy.jar
  • Unable to deploy an EAR application
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.subunit."ear_example.ear"."jar_example".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."ear_example.ear"."jar_example".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of subdeployment "jar_example" of deployment "ear_example.ear"
 (...)
 Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0041: Component class Drawbase.dwm.ejb.session.ConverterBean for component ConverterBean has errors: 
 WFLYJPA0033: Can't find a persistence unit named EjbModulePU in subdeployment "jar_example" of deployment "ear_example.ear"

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x
    • 8.x
  • Jakarta Persistence / Java Persistence API (JPA)

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