在 WildFly 8 中部署 EAR 应用程序时出现问题,找不到持久性单元
Issue deploying EAR Application in WildFly 8, can't find persistence UNIT
我正在创建一个 Java EE/7 EAR 应用程序,目标 AS 使用 WildFly 8.2。我注意到的第一件事是我的 ds.xml 文件没有在服务器中定义任何 DS,我必须手动创建它。注入 EntityManage 的第二个 y 类 具有以下注释:
@PersistenceContext(unitName = "DebitoAutomaticoMockDS")
private EntityManager em;
但在那之后部署 WildFly 时仍然出现以下错误:
Deployment failed: DebitoAutomaticoMock-ear.ear: { "outcome" : "failed", "failure-description" : { "JBAS014671: Failed services" : {"jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".INSTALL" : "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".INSTALL: JBAS018733: Failed to process phase INSTALL of subdeployment \"DebitoAutomaticoMock-ejb.jar\" of deployment \"DebitoAutomaticoMock-ear.ear\"\n Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class bo.com.sintesis.debito.mock.service.MemberRegistration for component MemberRegistration has errors: \nJBAS011440: Can't find a persistence unit named DebitoAutomaticoMockDS in subdeployment \"DebitoAutomaticoMock-ejb.jar\" of deployment \"DebitoAutomaticoMock-ear.ear\""}, "JBAS014771: Services with missing/unavailable dependencies" : [ "jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration.InAppClientContainer is missing [jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration]", "jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration.Validator is missing [jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"javax.faces.webapp.FacetTag\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration.ValidatorFactory is missing [jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration]", "jboss.naming.context.java.module.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-web.DefaultDataSource is missing [jboss.naming.context.java.jboss.datasources.WebServicesDS]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".weld.weldClassIntrospector is missing [jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".beanmanager]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"bo.com.sintesis.debito.mock.Servicios\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.unit.\"DebitoAutomaticoMock-ear.ear\".deploymentCompleteService is missing [jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".deploymentCompleteService]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"bo.com.sintesis.debito.bancos.ServicioDebito\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration.InstanceName is missing [jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration]", "jboss.deployment.unit.\"DebitoAutomaticoMock-ear.ear\".WeldStartService is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\", jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".jndiDependencyService]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"bo.com.sintesis.debito.bancos.ServiciosBanco\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"com.sun.xml.ws.transport.http.servlet.WSServletContextListener\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"com.sun.faces.config.ConfigureListener\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"com.sun.xml.ws.transport.http.servlet.WSAsyncListener\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]" ] }, "rolled-back" : true }
我很困惑,因为我的持久化单元如下:
<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">
<!-- If you are running in a production environment, add a managed
data source, this example data source is just for development and testing! -->
<!-- The datasource is deployed as <EAR>/META-INF/DebitoAutomaticoMock-ds.xml, you
can find it in the source at ear/src/main/application/META-INF/DebitoAutomaticoMock-ds.xml -->
<jta-data-source>java:jboss/datasources/DebitoAutomaticoMockDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
求指点,实在找不到问题
@PersistenceContext(unitName = "") 中的单位名称应与 <persistence-unit name="primary">
中定义的相同
你的情况是 "primary" 而不是 "DebitoAutomaticoMockDS"。
解决方法:
@PersistenceContext(unitName = "primary")
我正在创建一个 Java EE/7 EAR 应用程序,目标 AS 使用 WildFly 8.2。我注意到的第一件事是我的 ds.xml 文件没有在服务器中定义任何 DS,我必须手动创建它。注入 EntityManage 的第二个 y 类 具有以下注释:
@PersistenceContext(unitName = "DebitoAutomaticoMockDS")
private EntityManager em;
但在那之后部署 WildFly 时仍然出现以下错误:
Deployment failed: DebitoAutomaticoMock-ear.ear: { "outcome" : "failed", "failure-description" : { "JBAS014671: Failed services" : {"jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".INSTALL" : "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".INSTALL: JBAS018733: Failed to process phase INSTALL of subdeployment \"DebitoAutomaticoMock-ejb.jar\" of deployment \"DebitoAutomaticoMock-ear.ear\"\n Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class bo.com.sintesis.debito.mock.service.MemberRegistration for component MemberRegistration has errors: \nJBAS011440: Can't find a persistence unit named DebitoAutomaticoMockDS in subdeployment \"DebitoAutomaticoMock-ejb.jar\" of deployment \"DebitoAutomaticoMock-ear.ear\""}, "JBAS014771: Services with missing/unavailable dependencies" : [ "jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration.InAppClientContainer is missing [jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration]", "jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration.Validator is missing [jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"javax.faces.webapp.FacetTag\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration.ValidatorFactory is missing [jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration]", "jboss.naming.context.java.module.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-web.DefaultDataSource is missing [jboss.naming.context.java.jboss.datasources.WebServicesDS]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".weld.weldClassIntrospector is missing [jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".beanmanager]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"bo.com.sintesis.debito.mock.Servicios\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.unit.\"DebitoAutomaticoMock-ear.ear\".deploymentCompleteService is missing [jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".deploymentCompleteService]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"bo.com.sintesis.debito.bancos.ServicioDebito\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration.InstanceName is missing [jboss.naming.context.java.comp.DebitoAutomaticoMock-ear.DebitoAutomaticoMock-ejb.MemberRegistration]", "jboss.deployment.unit.\"DebitoAutomaticoMock-ear.ear\".WeldStartService is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\", jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-ejb.jar\".jndiDependencyService]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"bo.com.sintesis.debito.bancos.ServiciosBanco\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"com.sun.xml.ws.transport.http.servlet.WSServletContextListener\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"com.sun.faces.config.ConfigureListener\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]", "jboss.deployment.subunit.\"DebitoAutomaticoMock-ear.ear\".\"DebitoAutomaticoMock-web.war\".component.\"com.sun.xml.ws.transport.http.servlet.WSAsyncListener\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]" ] }, "rolled-back" : true }
我很困惑,因为我的持久化单元如下:
<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">
<!-- If you are running in a production environment, add a managed
data source, this example data source is just for development and testing! -->
<!-- The datasource is deployed as <EAR>/META-INF/DebitoAutomaticoMock-ds.xml, you
can find it in the source at ear/src/main/application/META-INF/DebitoAutomaticoMock-ds.xml -->
<jta-data-source>java:jboss/datasources/DebitoAutomaticoMockDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
求指点,实在找不到问题
@PersistenceContext(unitName = "") 中的单位名称应与 <persistence-unit name="primary">
你的情况是 "primary" 而不是 "DebitoAutomaticoMockDS"。
解决方法: @PersistenceContext(unitName = "primary")