5 Replies Latest reply on Feb 27, 2015 3:38 AM by Ayush Mathur

    How to get REST service working in Wildfly with RestEasy

    David Jensen Newbie

      Can someone please provide me the secret recipe for getting REST services to work in Wildfly-8.1.0-Final using RestEasy (the built-in one).

      Here is what I've tried:


      I have a simple REST service:



      public class FooRest {


           public Response simpleGet() {

                return Response.status(Response.Status.OK.entity("ok").type(MediaType.TEXT_PLAIN).build();




      Simple, right?  (Believe me, I've written much more complex ones... and the "foo" example above is just to keep things simple).


      Then in my web.xml, I have the following:













      I attempt to access the REST service by: http://localhost:8080/myApp/rs/foo


      All of this works fine using Jersey on Tomcat.


      The error I get is: [org.jboss.resteasy.core.ExceptionHandler] (default task-15) failed to execute: javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8080/myApp/rs/foo

      Any ideas?



      P.S. I find "RestEasy" not so "easy"..... I mean that "resteasy.servlet.mapping.prefix" thing is ridiculous (tell me why I'm wrong).

        • 1. Re: How to get REST service working in Wildfly with RestEasy
          Stephen Coy Master

          Do you have one of these?

          import javax.ws.rs.ApplicationPath;
          import javax.ws.rs.core.Application;
          public class JaxRsActivator extends Application {


          Also, no web.xml at all is required anymore.

          • 2. Re: How to get REST service working in Wildfly with RestEasy
            Arun Gupta Newbie

            There are tons of JAX-RS samples at: https://github.com/javaee-samples/javaee7-samples/tree/master/jaxrs


            All of them work using RESTEasy and WildFly.

            1 of 1 people found this helpful
            • 3. Re: How to get REST service working in Wildfly with RestEasy
              David Jensen Newbie

              I did not have one of those. So I created one and then removed what I had in web.xml.  It still doesn't work.  In-fact, I'm no longer getting the "Could not find resource for full path", instead I'm getting a 404 error when attempting to call the REST service.  I think I'm having interference from something else because I tried Arun Gupta's "jaxrs-endpoint" example and it worked fine.  This is an older web-app we are migrating to Wildfly and it uses Spring and Struts, so I'm wondering if one of them is interfering?


              But regardless, your answer was definitely what is needed to get the REST service to work (as proved by Arun Gupta's example.... nice job Arun!).

              • 4. Re: How to get REST service working in Wildfly with RestEasy
                David Jensen Newbie

                Hi Arun, you're jaxrs-endpoint example worked well (I downloaded and successfully ran it), and it proved that only an Application.java file is needed (without anything in web.xml).  But I'm still unable to successfully get a REST service running.  As stated above, I'm wondering if other parts of the web-app are interfering.  The web-app is older, but I've upgraded to Java 8 and everything else seems to work fine.  I've even added some EE 7 - JMS 2 stuff to it and that works fine.  It is only the REST stuff which I can't get.

                • 5. Re: How to get REST service working in Wildfly with RestEasy
                  Ayush Mathur Newbie

                  Hi David,

                  I'm facing the similar issue as yours wherein I have deployed a war packaged REST service in JBOSS EAP 6.1. However, I'm not able to access my service wither through browser or my rest client. Following is the error stack while running rest client:

                  Exception in thread "main" javax.ws.rs.NotFoundException: HTTP 404 Not Found

                    at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:913)

                    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:822)

                    at org.glassfish.jersey.client.JerseyInvocation.access$600(JerseyInvocation.java:90)

                    at org.glassfish.jersey.client.JerseyInvocation$3.call(JerseyInvocation.java:693)

                    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)

                    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)

                    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)

                    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)

                    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:689)

                    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:405)

                    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:301)

                    at com.psiincontrol.alarmservice.jaxrs.client.AlarmRestClient.getAlarms(AlarmRestClient.java:55)

                    at com.psiincontrol.alarmservice.jaxrs.client.AlarmRestClientTest.main(AlarmRestClientTest.java:28)


                  Any idea how this can be resolved ? The JBOSS logs doesn't show any error and deployed the service successfully.