Wildfly PersistenceUnit missing dependencies [closed]

0

I am trying to make a Web Service using wildfly-10.0.0.Final

I am getting the error shown bellow. I already copied / created postgres and eclipselink jars to the Wildfly module folders.

05:13:11,312 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "RESTendJPA-1.war")]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"RESTendJPA-1.war#myPS\" is missing [jboss.naming.context.java.DefaultProject]"]}

I have created a datasource through Wildfly administration UI. At the UI, wildfly connects successfully to the datasource. The standalone.xml datasource configuration is shown bellow.

<datasource jta="true" jndi-name="java:/DefaultProject" pool-name="DefaultProject" enabled="true" use-ccm="true">
                <connection-url>jdbc:postgresql://localhost:5432/defaultproject</connection-url>
                <driver-class>org.postgresql.Driver</driver-class>
                <driver>postgresql-9.4.1208.jre7.jar</driver>
                <security>
                    <user-name>defaultproject</user-name>
                    <password>defaultproject123</password>
                </security>
                <validation>
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
                    <background-validation>true</background-validation>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
                </validation>
            </datasource>

persistance.xml

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="myPS" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>java:/DefaultProject</jta-data-source>
</persistence-unit>

ApplicationConfig.java

@javax.ws.rs.ApplicationPath("restendjpa")
public class ApplicationConfig extends Application {

@Override
public Set<Class<?>> getClasses() {
    Set<Class<?>> resources = new java.util.HashSet<>();
    addRestResourceClasses(resources);
    return resources;
}

private void addRestResourceClasses(Set<Class<?>> resources) {
    resources.add(br.com.willian.restendjpa.entities.NewCrossOriginResourceSharingFilter.class);
    resources.add(br.com.willian.restendjpa.rest.ResourceFacadeREST.class);
}
}

ResourceFacadeREST

@Stateless
@Path("/resource")
public class ResourceFacadeREST extends AbstractFacade<Resource> {

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

public ResourceFacadeREST() {
    super(Resource.class);
}

@POST
@Override
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public void create(Resource entity) {
    super.create(entity);
}

@PUT
@Path("{id}")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public void edit(@PathParam("id") Integer id, Resource entity) {
    super.edit(entity);
}

@DELETE
@Path("{id}")
public void remove(@PathParam("id") Integer id) {
    super.remove(super.find(id));
}

@GET
@Path("{id}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Resource find(@PathParam("id") Integer id) {
    return super.find(id);
}

@GET
@Override
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Resource> findAll() {
    return super.findAll();
}

@GET
@Path("{from}/{to}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Resource> findRange(@PathParam("from") Integer from,
  @PathParam("to") Integer to) {
    return super.findRange(new int[]{from, to});
}

@GET
@Path("count")
@Produces(MediaType.TEXT_PLAIN)
public String countREST() {
    return String.valueOf(super.count());
}

@Override
protected EntityManager getEntityManager() {
    return em;
}
}
    
asked by anonymous 12.07.2016 / 10:38

1 answer

1

Hi! The persistence provider seems to me wrong.

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

From what I remember Wildfly uses Hibernate so it would be the one below:

<provider>org.hibernate.ejb.HibernatePersistence</provider>

Replace this in your persistence.xml and tell me if it worked.

  • Tip: If you are using the dependencies of the server and you are leaving it with the dependencies, you do not have to put this information, because servers like Wildfly or Glassfish manage to define this leading to the implementation that they have shipped , is mandatory even on a tomcat or jetty that does not have this feature.

Speak to us, it's settled.

    
12.07.2016 / 14:45