3

I tried working on it. But,not able to figure out the issue since I'm quite new to this. I have attached several screenshots to see the issue I'm facing right now.

enter image description here

enter image description here

enter image description here

enter image description here

@Path("/emp")
public class EmployeeService {

@GET
@Path("/emp/{empID}")
@Produces(MediaType.APPLICATION_XML)
public Employee getEmployee(@PathParam(value = "empID") String empID) {
    Employee employee = new Employee();
    employee.setEmailId(empID);
    employee.setName("Rony John");
    employee.setEmailId("rony.java@gmail.com");
    return employee;
}

@POST
@Path("/create")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public Employee createEmployee(Employee employee) {
    // Create logic
    return employee;

}

@POST
@Path("/update")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public Employee updateEmployee(Employee employee) {
    employee.setName(employee.getName() + " updated");
    return employee;
}

@DELETE
@Path("/delete/{empID}")
public Response deleteEmployee(@PathParam(value = "empID") String empID) {
    return Response.status(200)
            .entity("Employee with " + empID + " is deleted successfully.")
            .build();

}

}

AppSensei
  • 8,270
  • 22
  • 71
  • 99
  • What does your `EmployeeService` class look like? – condit Mar 14 '13 at 14:54
  • 1
    Does http://localhost:8080/JerseyRESTCRUD/emp/test do anything? What are you expecting to see at http://localhost:8080/JerseyRESTCRUD/? – condit Mar 14 '13 at 18:35

1 Answers1

3

The lack of providers is not relevant, it just means you don't have any.

You have an index.jsp, but if you mapped the Jersey filter at the context root (/), it's rightfully saying there's no resource there - based on your screenshots you only have one resource, starting at /emp which has sub-resources for the CRUD operations at deeper paths.

Edit: On second look, your index.jsp is in WEB-INF. I don't think it should be based on the fact you appear to be trying to get a simple example together.

So, what do you expect to see at /JerseyRESTCRUD/?

Doug Moscrop
  • 4,479
  • 3
  • 26
  • 46
  • I just had to place the index.html in the WebContent Folder. I still can't figure out how these URL's work. – AppSensei Mar 14 '13 at 18:45
  • 3
    Your web application is JerseyRESTCRUD, so that's the application context. Everything is going to be relative to that. So when you made your EmployeeService with a @Path of `emp`, it is at /JerseyRESTCRUD/emp -- then each of the methods that are within that class have *their* @Path appended, so e.g. `/JerseyRESTCRUD/emp/update`. When a request comes it has to be handled somehow - and one of those things is going to be Jersey, it's going to look at it's resources and @Paths and see if there is a match. You also are using JSP, so there's a servlet that will look (in WebContent) to matches. – Doug Moscrop Mar 14 '13 at 18:49