I have a webapp with the following resource:
@Path("/actor/{id}")
@RequestScoped
public class ActorResource {
@Inject SakilaBean sakila;
@GET
@Produces("application/json")
public Actor getActor(@PathParam("id") int id) {
System.out.println("id: " + id);
return sakila.findActorById(id);
}
}
This is deployed as simplewebapp.war on GlassFish v3.
http://localhost:8080/simplewebapp/actor/4
gives a 404. However adding:
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/sakila/*</url-pattern>
</servlet-mapping>
to web.xml, then the resource is available at:
http://localhost:8080/simplewebapp/sakila/actor/4.
Why Jersey servlet need to be registered explicitly ?
-Arun
--
Need Application Server ? Download from http://glassfish.org
Blog: http://blogs.sun.com/arungupta