7 Replies Latest reply on Dec 9, 2015 9:34 AM by Wolfgang Mayer

    JAX-RS helloworld on Wildfly 10

    Bertrand Pestre Newbie

      Hi everyone,

       

      I have an issue with this quickstart:

      https://github.com/wildfly/quickstart/tree/10.x/helloworld-rs

       

      I am using jdk1.8.0_66, wildfly-10.0.0.CR4 and maven 3.3.3.

       

      So I can deploy the application without any problem using the command: mvn clean install wildfly:deploy

      And I can see that the application is deployed and works at http://localhost:8080/jboss-helloworld-rs

      But when I try http://localhost:8080/wildfly-helloworld-rs/rest/json to get the xml content I get: "Not Found". Same for json.

      It seems that there is an issue with JAX-RS.


        • 1. Re: JAX-RS helloworld on Wildfly 10
          Luis Canales Newbie

          Hi,

           

          I think @Path("/") should be @Path("/rest") in HelloWorld.java file.

           

          Regards.

          Luis.

          • 2. Re: JAX-RS helloworld on Wildfly 10
            Bertrand Pestre Newbie

            Hi,

             

            Yes indeed I also think the path should be @Path("/rest").

            I changed it but I get the same: "Not Found" ...

            • 3. Re: JAX-RS helloworld on Wildfly 10
              Wolfgang Mayer Master

              I think there is a class missing which extends Application.

              It should work if you add another file which looks like

               

              package org.jboss.as.quickstarts.rshelloworld;

               

              import javax.ws.rs.ApplicationPath;

              import javax.ws.rs.core.Application;

               

              @ApplicationPath("rest")

               

              public class JAXRSConfig extends Application {

                  public JAXRSConfig() {

                  }

              }

              • 4. Re: JAX-RS helloworld on Wildfly 10
                Bertrand Pestre Newbie

                Hi,

                 

                So I my class now extends Application:

                 

                @ApplicationPath("/rest")

                public class HelloWorld extends Application {

                    @Inject

                    HelloService helloService;

                 

                    @GET

                    @Path("/json")

                    @Produces({ "application/json" })

                    public String getHelloWorldJSON() {

                        return "{\"result\":\"" + helloService.createHelloMessage("World") + "\"}";

                    }

                 

                    @GET

                    @Path("/xml")

                    @Produces({ "application/xml" })

                    public String getHelloWorldXML() {

                        return "<xml><result>" + helloService.createHelloMessage("World") + "</result></xml>";

                    }

                }

                 

                When I go to this url: http://localhost:8080/wildfly-helloworld-rs/rest/json I have this error:

                 

                16:53:20,919 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-7) RESTEASY002010: Failed to execute: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/wildfly-helloworld-rs/rest/json

                  at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:75)

                  at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)

                  at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:445)

                  at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:254)

                  at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:191)

                  at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)

                  at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)

                  at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)

                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

                  at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

                  at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

                  at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

                  at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

                  at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

                  at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

                  at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

                  at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)

                  at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)

                  at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                  at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)

                  at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)

                  at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

                  at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)

                  at io.undertow.server.Connectors.executeRootHandler(Connectors.java:198)

                  at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:788)

                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                  at java.lang.Thread.run(Thread.java:745)

                • 5. Re: JAX-RS helloworld on Wildfly 10
                  Wolfgang Mayer Master

                  I am not absolutely sure what you did here.

                  But as mentioned before you should not change anything in the source file but add an add'l java class that extends Application

                  • 6. Re: JAX-RS helloworld on Wildfly 10
                    Bertrand Pestre Newbie

                    Indeed it works fine ! Thank you very much.

                    So in wildfly 10 if I want to deploy a JAX-RS webservice I need to add this class ? And this class only extends Application and specify the ApplicationPath right ?

                    • 7. Re: JAX-RS helloworld on Wildfly 10
                      Wolfgang Mayer Master

                      I don't think this is related to WildFly 10 but documented in the API ApplicationPath (Java EE 6 )

                      "ApplicationPath Identifies the application path that serves as the base URI for all resource URIs provided by Path. May only be applied to a subclass of Application"