JBoss EAP 7.1 部署失败:WFLYCTL0013:操作 ("deploy") 失败
JBoss EAP 7.1 Deployment Failed : WFLYCTL0013: Operation ("deploy") failed
我的项目是 war 部署。
XXX.war
对于我的项目,有一个数据源 (ds) 安装在 jboss。
另外 XXX.war
对 xxx-domain.jar
有 maven 依赖,它处理 hibernate/persistence 配置。
这是我的 persistence.xml
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/xxxDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.session_factory_name" value="XXXSessionFactory"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" />
</properties>
</persistence-unit>
</persistence>
这是hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="java:jboss/XXXSessionFactory">
<property name="connection.datasource">java:xxxDS</property>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="current_session_context_class">thread</property>
<mapping resource="com/xxx/model/XXXModel.hbm.xml"/>
</session-factory>
</hibernate-configuration>
这 2 个配置存在于 xxx-domain.jar
。
当我尝试使用 jboss-as:deploy
部署它时。它给了我以下错误
15:58:22,288 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."XXX.war".FIRST_MODULE_USE: org.jboss.msc.service.StartException
in service jboss.deployment.unit."XXX.war".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment "XXX.war"
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deployPersistenceUnitPhaseOne(PersistenceUnitServiceHandler.java:558)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.addPuService(PersistenceUnitServiceHandler.java:279)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.handleWarDeployment(PersistenceUnitServiceHandler.java:206)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deploy(PersistenceUnitServiceHandler.java:134)
at org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor.deploy(PersistenceBeginInstallProcessor.java:52)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
... 5 more
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit."XXX.war#primary".__FIRST_PHASE__ is already registered
at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:158)
at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:235)
at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:768)
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2555)
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2555)
at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:317)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deployPersistenceUnitPhaseOne(PersistenceUnitServiceHandler.java:554)
... 10 more
15:58:22,292 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 23) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "XXX.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"XXX.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit.\"XXX.war#primary\".__FIRST_PHASE__ is already registered"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE"]
}
15:58:22,293 ERROR [org.jboss.as.server] (management-handler-thread - 23) WFLYSRV0021: Deploy of deployment "XXX.war" was rolled back with the following failure message:
{
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"XXX.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit.\"XXX.war#primary\".__FIRST_PHASE__ is already registered"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE"]
有人可以帮我找出问题所在吗??
Jboss EAP 7.1 自带hibernate版本 version > 4.3.
如果你检查这个 link: https://docs.jboss.org/author/display/WFLY10/JPA+Reference+Guide#JPAReferenceGuide-UpdateyourPersistence.xmlforHibernate5.0 它说而不是使用:
<provider>org.hibernate.ejb.HibernatePersistence</provider>
在您的 persistence.xml
中,您应该使用:
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
.
当然前提是你使用的是容器的休眠版本。
这是 Jboss 服务器中的已知 CDI 问题。
您不需要这两个文件,但如果需要,请尝试在 persistence.xml:
中添加此 属性
hibernate.ejb.cfgfile
使用 hibernate.cfg.xml 的路径并删除 jta-data-source。
或者尝试设置 属性
hibernate.temp.use_jdbc_metadata_defaults
为假。
更新
我也找到了 issue。
我的项目是 war 部署。
XXX.war
对于我的项目,有一个数据源 (ds) 安装在 jboss。
另外 XXX.war
对 xxx-domain.jar
有 maven 依赖,它处理 hibernate/persistence 配置。
这是我的 persistence.xml
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/xxxDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.session_factory_name" value="XXXSessionFactory"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" />
</properties>
</persistence-unit>
</persistence>
这是hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="java:jboss/XXXSessionFactory">
<property name="connection.datasource">java:xxxDS</property>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="current_session_context_class">thread</property>
<mapping resource="com/xxx/model/XXXModel.hbm.xml"/>
</session-factory>
</hibernate-configuration>
这 2 个配置存在于 xxx-domain.jar
。
当我尝试使用 jboss-as:deploy
部署它时。它给了我以下错误
15:58:22,288 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."XXX.war".FIRST_MODULE_USE: org.jboss.msc.service.StartException
in service jboss.deployment.unit."XXX.war".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment "XXX.war"
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deployPersistenceUnitPhaseOne(PersistenceUnitServiceHandler.java:558)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.addPuService(PersistenceUnitServiceHandler.java:279)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.handleWarDeployment(PersistenceUnitServiceHandler.java:206)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deploy(PersistenceUnitServiceHandler.java:134)
at org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor.deploy(PersistenceBeginInstallProcessor.java:52)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
... 5 more
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit."XXX.war#primary".__FIRST_PHASE__ is already registered
at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:158)
at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:235)
at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:768)
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2555)
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2555)
at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:317)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deployPersistenceUnitPhaseOne(PersistenceUnitServiceHandler.java:554)
... 10 more
15:58:22,292 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 23) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "XXX.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"XXX.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit.\"XXX.war#primary\".__FIRST_PHASE__ is already registered"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE"]
}
15:58:22,293 ERROR [org.jboss.as.server] (management-handler-thread - 23) WFLYSRV0021: Deploy of deployment "XXX.war" was rolled back with the following failure message:
{
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"XXX.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0038: Failed to add persistence unit service for primary
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.persistenceunit.\"XXX.war#primary\".__FIRST_PHASE__ is already registered"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"XXX.war\".FIRST_MODULE_USE"]
有人可以帮我找出问题所在吗??
Jboss EAP 7.1 自带hibernate版本 version > 4.3.
如果你检查这个 link: https://docs.jboss.org/author/display/WFLY10/JPA+Reference+Guide#JPAReferenceGuide-UpdateyourPersistence.xmlforHibernate5.0 它说而不是使用:
<provider>org.hibernate.ejb.HibernatePersistence</provider>
在您的 persistence.xml
中,您应该使用:
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
.
当然前提是你使用的是容器的休眠版本。
这是 Jboss 服务器中的已知 CDI 问题。 您不需要这两个文件,但如果需要,请尝试在 persistence.xml:
中添加此 属性hibernate.ejb.cfgfile
使用 hibernate.cfg.xml 的路径并删除 jta-data-source。 或者尝试设置 属性
hibernate.temp.use_jdbc_metadata_defaults
为假。
更新
我也找到了 issue。