Create RESTful Web Service with JAX-RS and deploy it to tomcat

Viewed 25468

I'm trying to create and deploy a RESTful Web Service using JAX-RS and deploy it to tomcat. I don't want to use any IDE. In Tomcat I have the following directory structure inside webapps\

notifire\WEB-INF\
                 |
                 ---> web.xml
                 |
                 ---> \classes/Notifier.class
                 |
                 ---> \lib\javax.ws.rs-api-2.0

my web.xml contains:

<servlet>
<servlet-name>Web Service Servlet</servlet-name>
<servlet-class>javax.ws.rs.core.Application</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Web Service Servlet</servlet-name>
<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>

and the class file Notifier.class was compiled from the file Notifier.java.

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;

@Path("notifier")
public class Notifier {

    @Context
    private UriInfo context;

    @GET
    @Produces("text/html")
    public String getHTML() {

         return "<p></p>";
    }
}

When I try to access the Web Service at http://localhost:8080/notifire/webservice/notifier I get the following error:

--type Exception report

--message Class javax.ws.rs.core.Application is not a Servlet

--description The server encountered an internal error that prevented it from fulfilling this request.

Any help is appreciated.

2 Answers
Related