I am trying to get resteasy working on JBoss AS6 Final (SEAM 2 app), but I cant seem the get the most basic example working, as I understand it, resteasy should be ready to go, I have tried the following example from here but the urls simply result in 404 errors with no response
package uk.co.rest.test;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;
public class Library extends Application {
@GET
@Path("/books")
public String getBooks() {
System.out.println("Check");
return "done";
}
}
with the following added to my web.xml
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<servlet>
<servlet-name>resteasy-servlet</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>uk.co.rest.test.Library</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
I get the feeling that the resteasy.deployer that is bundled with JBoss is not doing its job, but im not sure how to go about debugging it
Any help would be great im pulling my hair out over this one!!
RESTEasy must be configured in order to be exposed as a service. You can do it either directly or via Seam’s resource servlet.
To use RESTEasy directly, I find the easiest way is configuring it as a Servlet filter. There’s little to do other than adding the filter to your
web.xmlas documented in http://docs.jboss.org/resteasy/docs/2.3.0.GA/userguide/html/Installation_Configuration.html#filter.When using Seam this is however unnecessary, as Seam is capable of deploying RESTEasy services via its resource servlet quite simply (documented in http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/webservices.html#d0e22093). You first declare RESTEasy’s application component like this:
And create your providers that will be automatically deployed into the configured path, for example:
You can then access the RESTEasy service via:
The advantage of going the Seam way is mostly ease of use. You do need to include an extra jar:
jboss-seam-resteasy.jar.