users@jersey.java.net

[Jersey] Re: REST web service with Jersey giving 404 error

From: banerjpa <banerjeeparamita_at_yahoo.com>
Date: Tue, 3 Apr 2012 16:19:26 -0700 (PDT)

Hi,

Is your problem resolved, I am using the same example that you have posted
and 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 "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
        }

        // This method is called if HTML is request
        @GET
        @Produces(MediaType.TEXT_HTML)
        public String sayHtmlHello() {
                return "<html> " + "<title>" + "Hello Jersey" + "</title>"
                                + "<body>
" + "Hello Jersey" + "</body>
" + "</html> ";
        }

}


Here 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_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
  <display-name>RESTfulWeb</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  
  <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.sun.jersey.resources</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 deployed the application in weblogic 11g, and I have kept all the jersey
jars in WEB-INF/lib

the url I am trying to invoke is:

http://localhost:7001/com.sun.jersey.resources/rest/hello

Appreciate any help! Hoping to see a response if you have already resolved
it.

thanks!

--
View this message in context: http://jersey.576304.n2.nabble.com/REST-web-service-with-Jersey-giving-404-error-tp5730874p7434826.html
Sent from the Jersey mailing list archive at Nabble.com.