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