Unable to run Jersey web service on tomcat

Viewed 3344

I have developed a simple rest web service using Jersey 1.17.1 and deployed in Tomcat 7.0.41. However I am getting 404 response (The requested resource is not available) when hitting the service URL. I did find the below statement in tomcat log, not able to figure out why - com.sun.jersey.api.core.ScanningResourceConfig init INFO: No provider classes found.

Below is the code I am using :-

package com.test.rest.service;
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("persolazation")
public class PersolazationService { 
@GET       
@Path("/name/{i}") 
@Produces(MediaType.TEXT_XML)       
public String userName(@PathParam("i") String i) {       
String name = i; 
return "<User>" + "<Name>" + name + "</Name>" + "</User>"; 
}            
}

and web.xml is below :-

<?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">   
  <display-name>RESTfulWS</display-name>   
  <servlet>   
    <servlet-name>Jersey REST Service</servlet-name>   
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>   
    <init-param>   
      <param-name>com.sun.jersey.config.property.packages</param-name>   
      <param-value>com.test.rest.service</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 am using the following URL to call the service :- http://:8080/RESTfulWS/rest/persolazation/name/Robert .

Catalina.out logs are below -
INFO: Deploying web application archive /usr/local/tomcat/apache-tomcat-7.0.47/webapps/RestfulWS.war
Dec 26, 2013 11:56:08 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
  com.test.rest.service
Dec 26, 2013 11:56:08 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
  class com.test.rest.service.PersolazationService
Dec 26, 2013 11:56:08 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Dec 26, 2013 11:56:08 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.17.1 02/28/2013 12:47 PM'
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Please advise.

Thanks, Deep

1 Answers
Related