Search code examples
jpawildfly-8

Issue deploying EAR Application in WildFly 8, can't find persistence UNIT


I'm creating a Java EE/7 EAR application, and as destination AS use WildFly 8.2. First thing I've noted is that my ds.xml file doesn't define any DS in the server, I had to create it manually. Second y classes that inject EntityManage have the following annotations:

@PersistenceContext(unitName = "DebitoAutomaticoMockDS")
private EntityManager em;

But still after that when deploying WildFly gives me the following error:

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$1\".START is missing [jboss.persistenceunit.\"DebitoAutomaticoMock-ear.ear/DebitoAutomaticoMock-ejb.jar#primary\"]" ] }, "rolled-back" : true }

I'm quite confused because my persistence unit is as follows:

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

Please give me some tips, I'really can't find the issue.


Solution

  • Your unitName in @PersistenceContext(unitName = "") should be the same as defined in <persistence-unit name="primary">

    in your case it's "primary" and not "DebitoAutomaticoMockDS".

    Solution: @PersistenceContext(unitName = "primary")