1 Reply Latest reply on Aug 25, 2016 12:20 PM by James Perkins

    [RestEasy] Problem to call a method of a very simple REST Web Service

    Thomas CAMPOS Newbie

      Hello everybody,


      I try to implement at home a simple rest web service in order to learn this technology.


      I use the latest version of JBoss EAP : the 7.
      I have created under Java 8 a Maven project.
      The deployment is ok but when i want to call a method of my REST Web Service, i have a 404 error.

      I follow what to do on specifications and tutorial.

       

      1) I create a WAR whose name is bddsorties.

       

      2) I have a class that extends the javax.ws.rs.core.Application class :
      public class App extends Application.
      This class is annotated :
      @ApplicationPath("/messorties")

       

       

      3) I have another class, my Web Service annotated with @Path :
      @Path("accueil")

      public class HelloWorld

       

      4) In this Web Service class called HelloWorld, there is a basic method that i want to call :
          @GET
          @Path("helloworld")
          public Response getHelloWorld() {
              String value = "Hello World Thomas in REST World";
              return Response.status(200).entity(value).build();
          }

       

      When i want to call this method by typing http://localhost:8080/sortiesbdd/messorties/accueil/helloworld,
      i have a 404 error :
      Error HTTP 404

      What is wrong in my code ?
      i am looking for a week, and i can't find a solution.

      Thank you in advance,
        Thomas


        • 1. Re: [RestEasy] Problem to call a method of a very simple REST Web Service
          James Perkins Master

          By default maven will append the version to the end of the archive. You need to make sure that "sortiesbdd" is the name of your archive or you include a jboss-web.xml file that indicates that's the context name you want to use.

           

          Generally the context is the name of your WAR file. If the name of your name of your WAR is something like "sortiesbdd-1.0-SNAPSHOT.war" then likely your context name is "sortiesbdd-1.0-SNAPSHOT". You should see a line on the console like the following which will show you the web context that was registered.

          09:15:15,948 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 24) WFLYUT0021: Registered web context: /batch-chunk

           

          In the example above "batch-chunk" is the context name.

          --

          James R. Perkins