0
votes

I want to create a simple JAX-RS REST Service for Wildfly 10. My issue is that my REST Service is not found. Result in browser is 404 not found. I am not sure what exactly the issue is. I get no error or exception in wildfly log file. I am using eclipse neon 3 and wildfly 10. My project is using JAX-RS not resteasy.

Here my project setup and code:

  1. I have created a Dynamic Web Project in Eclipse.
  2. I have set JAX-RS(REST Service) support in the project facets. JAX-RS version is 2.0 (also tried with version 1.1)
  3. I have create a subclass which extends Application (javax.ws.rs.core.Application)
  4. I added the annotation @ApplicationPath("/yoshi-rest") to the class which extends Application.
  5. I have created a class which contains my rest service method. The class itself has the @Path("/StatusService") annotation.
  6. The affected method has the annotations @Get and @Path("/getStatus").
  7. Due to I have the subclass of Application I didn't set the servlet mapping in web.xml.

Here the code:

Subclass of Application(RESTConfig):

@ApplicationPath("/yoshi-rest")
public class RESTConfig extends Application {

}

REST Service class(StatusService):

@Path("/StatusService")
public class StatusService {

  @Get
  @Path("/getStatus")
  public String getStatus() {
    return "Yoshi is up and running";
  }
}

I can see during startup of wildfly that the subclass RESTConfig is deployed:

11:09:23,777 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 61) RESTEASY002225: Deploying javax.ws.rs.core.Application: class XXXX.yoshi.rest.services.RESTConfig

If I call the rest service url (http://localhost:8080/yoshi-rest/StatusService/getStatus) in browser, I get a '404 - Not found' as result.

Any idea what I am doing wrong?

2
Try putting the project name in the front of the URL path after the localhost:8080/Paul Samsotha

2 Answers

0
votes

You need to register service to connect to your RESTConfig:

@ApplicationPath("/yoshi-rest")
public class RESTConfig extends ResourceConfig {
public RESTConfig() {
    register(StatusService.class);
}

See more on ResourceConfig configuration options

Standard JAX-RS uses an Application as its configuration class. ResourceConfig extends Application.

0
votes

Putting the project name in the url solved the issue.

Thanks for help.