I am attempting to take a simple REST example that I found online and deploy to GlassFish 4.0. I am using Eclipse (OEPE distribution) and GlassFish 4.0. When I attempt to "Run As --> Run on Server" the REST example seems to deploy, but I immediately get a HTTP status 404 - Not found error in Eclipse when it attempts to reach out to my context root (http://localhost:8080/RESTFullWS/
).
Everything seems to be in place based on what I have been reading, but I still cannot hit the context root nor my service endpoint from a browser. I think I am missing something obvious here, but not sure what is going on.
Service:
package com.example.rest;
@Path("UserInfoService")
public class UserInfo
{
@GET
@Path("/name/{i}")
@Produces(MediaType.TEXT_XML)
public String userName(@PathParam("i") String i)
{
String name = i;
return "<User>" + "<Name>" + name + "</Name>" + "</User>";
}
@GET
@Path("/age/{j}")
@Produces(MediaType.TEXT_XML)
public String userAge(@PathParam("j") int j)
{
int age = j;
return "<User>" + "<Age>" + age + "</Age>" + "</User>";
}
}
Web Context defined in glassfish-web.xml:
<glassfish-web-app>
<context-root>/RESTFullWS</context-root>
</glassfish-web-app>
http://localhost:8080/RESTFullWS/UserInfoService/name/bob -- gets me the 404.
Is my service even being deployed properly? How can i test?