简体   繁体   中英

Persistence unitName was not specified error when deploying to Jboss 7.1.0 EAP

I have an old war file, which I am trying to deploy in JBOss7.1.0 EAP but getting he following error. It was running in older version of JBoss

INFO  [org.jboss.as.jpa] (MSC service thread 1-1) WFLYJPA0002: Read persistence.xml for IcamBusiness
16:02:30,693 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.subunit."icam-e.ear"."icam-e-web-1.war".DEPENDENCIES: org.jboss.msc.service.StartException in service jboss.deployment.subunit."icam-e.ear"."icam-e-web-1.war".DEPENDENCIES: WFLYSRV0153: Failed to process phase DEPENDENCIES of subdeployment "icam-e-web-1.war" of deployment "icam-e.ear"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: WFLYJPA0061: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment subdeployment "icam-e-web-1.war" of deployment "icam-e.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:187)
        at org.jboss.as.jpa.container.PersistenceUnitSearch.findWithinDeployment(PersistenceUnitSearch.java:153)
        at org.jboss.as.jpa.container.PersistenceUnitSearch.findPersistenceUnitSupplier(

When I opened the old war file , I could see it has used the persistence.xml file and when trying to load the 'IcamBusiness', It is giving the error. I presume, I have to mention @PersistenceContext(unitName = "IcamBusiness") to fix this issue, but I dont have the source code for the war. Is there any way I can run this war file in JBoss7.1.0EAP. 在此处输入图片说明

The issue would be either on the addition of the persistence unit on the persistence.xml:

<property name="wildfly.jpa.default-unit" value="true"/>

Or on the definition:

  <persistence-unit name="primary">
      <jta-data-source>java:jboss/datasources/primary_ds</jta-data-source>
      <class>whatever.primary.model.SomeEntity</class>
      <exclude-unlisted-classes>true</exclude-unlisted-classes>
      <properties> ... </properties>
   </persistence-unit>

This question brings more information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM