The important part is: without web.xml.
I already have a working JAX-RS app running on Glassfish 3.1.2.2 without a web.xml, configured purely by annotations.
The question is, how can I maintain the web.xml-less nirvana and still use Jersey MVC to serve static resources from the resources or webapp directory of my Maven .war project?
I see in many answers how can I do this with web.xml configuration, but nobody mentions how to map resources without the web.xml file.
Currently I have a ui.html file under the resources directory, a JAX-RS Application subclass and a resource class. No web.xml in the project and the following is working well:
@Path("/ui")
@GET
public Response ui() {
String content = "Hello StackOverflow";
return Response.ok(content).build();
}
While this one is failing with the IOException from the resolver:
@Path("/ui")
@GET
public Response ui() {
Viewable viewable = new Viewable("/ui.html");
return Response.ok(viewable).build();
}
java.io.IOException: The template name, /ui.html, could not be resolved to a fully qualified template name
I also tried to specify it with a relative path, but that didn't work either.
The dependencies I'm using for Jersey are as follows:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.18</version>
</dependency>
I understand that a proper example project would be the best and willing to provide that if people are having a hard time figuring out what I'm talking about, just let me know.