I'm trying to deploy a simple web application under Jboss AS 7.1.1 which exposes JAX-RS services, using Resteasy. According to Resteasy docs (I've updated resteasy to 3.0 beta 2), there's no need to put anything in web.xml, so I created an empty web project in eclipse and used the following web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
</web-app>
I also have an application class:
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/rest")
public class MyApplication extends Application {
}
and a class to implement the actual service:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path( "/test" )
public class Login {
@GET
@Produces(MediaType.TEXT_HTML)
public Response login() {
return Response.ok( "logged in" ).build();
}
}
Unfortunately, when I startup the server and try to reach the application, I see a 404 error.
I also tried to run one of the examples bundled with Resteasy distribution (examples/oreilly-workbook-as7/ex03_1
) using maven but, after correctly build and deploy the war, it fails to run tests:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.restfully.shop.test.CustomerResourceTest
*** Create a new Customer ***
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.53 sec <<< FAILURE!
Results :
Failed tests: testCustomerResource(com.restfully.shop.test.CustomerResourceTest): expected:<201> but was:<404>
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
I can't figure out what am I missing. What's wrong with my project?