I have been trying to get this tutorial to work: Link I am using Apache Tomcat 7.0 and the Jersey 2.0 libraries. This is my service:
package org.arpit.javapostsforlearning.webservice; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("ConversionService") public class FeetToInchAndInchToFeetConversionService { @GET @Path("/InchToFeet/{i}") @Produces(MediaType.TEXT_XML) public String convertInchToFeet(@PathParam("i") int i) { int inch=i; double feet = 0; feet =(double) inch/12; return "<InchToFeetService>" + "<Inch>" + inch + "</Inch>" + "<Feet>" + feet + "</Feet>" + "</InchToFeetService>"; } @Path("/FeetToInch/{f}") @GET @Produces(MediaType.TEXT_XML) public String convertFeetToInch(@PathParam("f") int f) { int inch=0; int feet = f; inch = 12*feet; return "<FeetToInchService>" + "<Feet>" + feet + "</Feet>" + "<Inch>" + inch + "</Inch>" + "</FeetToInchService>"; } } and this is my 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:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 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>RESTfulWebServiceExample</display-name> <servlet> <servlet-name>Jersey REST Service</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>org.arpit.javapostsforlearning.webservice</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey REST Service</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> </web-app> I tried to Run it on server to deploy and I also tried to let eclipse export it as a war file and then deploy it with the tomcat application manager. Both ways I get the HTTP Status 404, The requested resource is not available. Prior to this there is error message in any logs. I have also tried to put a simple index.html file in the Webcontent folder, but I could also not access that in the browser. I know that there are a lot of similar posts on the forum, but after having read them and hours of trying i still cannot figure out how to solve my problem.