【问题标题】:Persistence unitName was not specified error when deploying to Jboss 7.1.0 EAP部署到 Jboss 7.1.0 EAP 时未指定持久性单元名称错误
【发布时间】:2020-01-05 22:19:47
【问题描述】:

我有一个旧的战争文件,我试图在 JBOss7.1.0 EAP 中部署它,但让他出现以下错误。它在旧版本的 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(

当我打开旧的战争文件时,我可以看到它使用了 persistence.xml 文件,并且在尝试加载“IcamBusiness”时,它给出了错误。 我想,我不得不提 @PersistenceContext(unitName = "IcamBusiness") 解决这个问题,但我没有战争的源代码。有什么办法可以在 JBoss7.1.0EAP 中运行这个 war 文件。

【问题讨论】:

    标签: java hibernate spring-mvc jpa jboss


    【解决方案1】:

    问题可能在于在 persistence.xml 中添加持久性单元:

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

    或者关于定义:

      <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>
    

    这个question带来更多信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-20
      • 1970-01-01
      • 1970-01-01
      • 2016-05-29
      • 2011-10-22
      • 2015-09-24
      • 2021-01-07
      • 2022-06-14
      相关资源
      最近更新 更多