Why is this Simple JAX RS example not working?

Viewed 19753

I am trying to get working a simple JAX RS example, but I am failing to do so.

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>PLAYGROUND</display-name>
  <servlet-mapping>
    <servlet-name>playground.Rest</servlet-name>
    <url-pattern>/api/*</url-pattern>
  </servlet-mapping>
</web-app>

Rest.java

package playground;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;

public class Rest extends Application {
    @GET
    @Path("hello")
    public String helloworld() {
        return "Hello World!";
    }
}

Accessing http://localhost/{warcontext}/api/hello with the browser (GET) gives me 404 error status

It is probably something very silly but I can't figure out.

Using: JBoss EAP 6.1.0 (Java EE 6)

4 Answers
Related