0 Replies Latest reply on Jan 6, 2013 6:12 AM by vjsingh

    Resteasy not working in servlet containers using 1) @ApplicationPath 2) Custom URL Pattern in HttpServletDispatcher using "resteasy.resources"

    vjsingh

      Hi,

       

      I am not sure whether this is the correct destination for the thread, but I did not find any other place.

       

      I am not being able to make Resteasy work with @ApplicationPath in servlet containers like Tomcat 7 or Jetty 8. My code is as follows:

       

      {code}

      @ApplicationPath("/rest")

      public class MyApplication extends Application {

       

                @Override

                public Set<Class<?>> getClasses() {

       

                          final Set<Class<?>> s = new HashSet<Class<?>>();

                          s.add(ViewController2.class);

                          return s;

                }

      }

       

      {code}

       

      {code}@Path("/")

      public class ViewController {

       

       

                @GET

                @Path("/test")

                public String test() {

                          return "Yes!";

                }

      }

      {code}

       

      Replacing Resteasy libs with jersey immediately solved the problem. Adding the following lines also did not resolve the problem:

       

      {code:xml}

      <servlet>

      <servlet-name>Resteasy</servlet-name>

      <servlet-class>

      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher

      </servlet-class>

      <init-param>

      <param-name>javax.ws.rs.Application</param-name>

      <param-value>testResteasy.MyApplication</param-value>

      </init-param>

      </servlet>

      <servlet-mapping>

      <servlet-name>Resteasy</servlet-name>

      <url-pattern>/rest/*</url-pattern>

      </servlet-mapping>

      {code}

       

      Then I looked up the given examples and was able to make it work using:

       

      {code:xml}

      <context-param>

      <param-name>resteasy.resources</param-name>

      <param-value>testResteasy.controller.ViewController</param-value>

      </context-param>

       

      <servlet>

      <servlet-name>Resteasy</servlet-name>

      <servlet-class>

      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher

      </servlet-class>

      </servlet>

      <servlet-mapping>

      <servlet-name>Resteasy</servlet-name>

      <url-pattern>/*</url-pattern>

      </servlet-mapping>

      {code}

       

      Nevertheless, I don't want all of my URI to be fecthed via Resteasy. So I changed the url-pattern to "/rest/*" and it again stopped working.

       

      I would really like to know the following 2 things:

      1. Why does @ApplicationPath not work whereas it works seamlessly using Jersey.
      2. When using "resteasy.resources" why does any other url-pattern other than " /* " not work?

       

      Regrads.

      Vikram.