Try creating a class that extends javax.ws.rs.core.Application and override getClasses() or getSingletons(). In either method you add your resoureces. For example:
<code>
@Override
public Set<Class<?>> getClasses() {
final Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(NameOfYourResource.class);
return classes;
}
</code>
Then in web.xml add an <init-param> to the com.sun.jersey.spi.container.servlet.ServletContainer like this:
<code>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>fully.qualified.package.name.of.the.ApplicationClass</param-value>
</init-param>
</code>
Works for me, hope it helps!
John Ruffin
-----Original Message-----
From: banerjpa [mailto:banerjeeparamita_at_yahoo.com]
Sent: Tuesday, April 3, 2012 06:19 PM
To: users_at_jersey.dev.java.net
Subject: [Jersey] Re: REST web service with Jersey giving 404 error
Hi,Is your problem resolved, I am using the same example that you have postedand facing exactly same issue 404 not found error.There is no error in weblogic log.here is my java resource class:package com.sun.jersey.resources;import javax.ws.rs.GET;import javax.ws.rs.Path;import javax.ws.rs.Produces;import javax.ws.rs.core.MediaType;//Sets the path to base URL + /hello@Path("/hello")public class Hello { // This method is called if TEXT_PLAIN is request @GET @Produces(MediaType.TEXT_PLAIN) public String sayPlainTextHello() { return "Hello Jersey"; } // This method is called if XML is request @GET @Produces(MediaType.TEXT_XML) public String sayXMLHello() { return "" + " Hello Jersey" + ""; } // This method is called if HTML is request @GET @Produces(MediaType.TEXT_HTML) public String sayHtmlHello() { return " " + "" + "Hello Jersey" + "" + "" + "Hello Jersey" + "" + " "; }}Here is my web.xml:RESTfulWebindex.htmlindex.htmindex.jspdefault.htmldefault.htmdefault.jspJersey REST Servicecom.sun.jersey.spi.container.servlet.ServletContainercom.sun.jersey.config.property.packagescom.sun.jersey.resources1Jersey REST Service/rest/*I deployed the application in weblogic 11g, and I have kept all the jerseyjars in WEB-INF/libthe url I am trying to invoke is:
http://localhost:7001/com.sun.jersey.resources/rest/helloAppreciate any help! Hoping to see a response if you have already resolvedit.thanks!--View this message in context:
http://jersey.576304.n2.nabble.com/REST-web-service-with-Jersey-giving-404-error-tp5730874p7434826.htmlSent from the Jersey mailing list archive at Nabble.com.