2

I am running a javaee web application from the ground up using wildfly and simply want to expose some RESTful web services. My wildfly application server is running with the defaults it shipped with and I am not using any database entities although I do have a persisitance.xml to make wildfly happy. My application deploys fine as indicated by log messages below.

12:50:38,585 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-5) Deploying javax.ws.rs.core.Application: class org.netbeans.rest.application.config.ApplicationConfig
12:50:38,585 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-5) Adding class resource os.acquisition.acq.Acquisition from Application class org.netbeans.rest.application.config.ApplicationConfig
12:50:38,588 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017534: Registered web context: /acq-1.0
12:50:38,712 INFO  [org.jboss.as.server] (management-handler-thread - 29) JBAS018565: Replaced deployment "acq-1.0.war" with deployment "acq-1.0.war"

My issue comes when trying to call the GET request below. (always returns 404)

@Path("/acq")
public class Acquisition {

    @GET
    @Path("ping")
    public Response ping(@Context HttpServletRequest req) {
        return Response.ok().entity(GenericResponse.OK).build();
    }

}

I have also used the standard IDE generated ApplicationConfig.java which has this service as one of its resources.

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

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

    /**
     * Do not modify addRestResourceClasses() method.
     * It is automatically populated with
     * all resources defined in the project.
     * If required, comment out calling this method in getClasses().
     */
    private void addRestResourceClasses(Set<Class<?>> resources) {
        resources.add(os.acquisition.acq.Acquisition.class);
    }

}

I have been using a short curl script to call the rest service and have tried every possible combination of @Path params and URL configurations to no avail.

#!/bin/bash
curl -v -X GET http://localhost:8080/acq-1.0/acq/ping

Additionally, when curl -v -X GET http://localhost:8080/acq-1.0/ is called it returns to me the index.html page as I expect.

It seems that I am missing something fundimental here. Any ideas?

1 Answers1

3

@ApplicationPath's value is appended to the resource URI before the individual resource paths. Looks like your curl request is missing the "webresources" portion.

whitlaaa
  • 892
  • 8
  • 15
  • 1
    I found that out only a few seconds before you posted this. I found it quite difficult to find reliable information on the topic. Thanks for your response. – Mike Meding Dec 23 '14 at 20:09