2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Rest Web services returning a 404?

In Eclipse I create simple RestWeb Service appliaction.I followed vogella tutorial.I took maven web application.

In Pom I added 1.17.1 version jersery related all the dependecies.

web.xml as


     <servlet-name>Jersey REST Service</servlet-name>
     <!-- Register resources and providers under com.ws.first package. -->
    <servlet-name>Jersey REST Service</servlet-name>

Java class is: Hello.java

public class Hello {

  // This method is called if TEXT_PLAIN is request
  public String sayPlainTextHello() {
    return "Hello Jersey";

  // This method is called if XML is request
  public String sayXMLHello() {

"<?xml version="1.0"?>" + "<hello> Hello Jersey" + "</hello>";

  // This method is called if HTML is request
  public String sayHtmlHello() {
    return "<html> " + "<title>" + "Hello Jersey" + "</title>"
        + "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> ";


Try the url as:localhost:8090/FirstWS/rest/hello

but it gives 404 error:: The requested resource is not available.


The things you trying to do to get the benefit of restful webservice i will not suggest to for that way:

The way i will prefer will be as below :

Maven pom.xml configuration:

Add repository:

            <name>Java.net Repository for Maven</name>

In web.xml add below method:

             <param-value>com.kodetalk.restful</param-value> <!-- The package where all the class file will present-->

Now i need to write the class file to access:

package com.kodetalk.restful;

import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

public class HelloWorldREST {

    public Response responseMsg( @PathParam("parameter") String parameter) {
        String output = "Parameter I passed : " + parameter + " : ";
        return Response.status(200).entity(output).build();
    public String responseMsg1() {
        return "Hellow world...";

The url will be : http://localhost:<port number>/kodetalk/kodetalk/resrHello // To display Hellow World...

and http://localhost:<port number>/kodetalk/kodetalk/send Parameter // Will print : Parameter I passed : send Parameter

The process you trying to do will cause lots of trouble so try as mentioned.


I got the answer. Previously I placed "web.xml" file in following folder structure

RestWebServiesProject --> src --> main --> webapp -->WEB-INF --> web.xml

But Now I changed it to WebContent Folder,so folder structure :

RestWebServiesProject --> WebContent --> WEB-INF --> web.xml

At time of creation "maven Project",it not create the WebContent folder by default,so I manually added the WebContent folder in my project.

Thanks Moe .I tried same thing in my system but it again gives same error
Answer is