I was experimenting with packaging resources in the META-INF/resources directory of a JAR which is then packaged into my WARs WEB-INF/lib directory and came across some odd behavior.
The Servlet 3.0 specification states that static content can be packaged in that way and will be delivered as such. The issue I am having with this is when I package content in a sub directory it is not found.
For example, if my JAR looks like so:
my-webjar.jar
-- com
/foo
/Main.class
-- META-INF
/resources
/index.html
and I package that JAR into a WAR like so:
my-webapp.war
-- WEB-INF
/lib
/my-webjar.jar
and then deploy this to Glassfish 3.1.2.2 and hit the URL
http://localhost:8080/my-webapp/index.html I see the index.html that is bundled in the JAR.
However, if I change the JARs layout to place index.html in a sub directory of the resources directory like so:
my-webjar.jar
-- com
/foo
/Main.class
-- META-INF
/resources
/foo
/index.html
and deploy this and access the URL
http://localhost:8080/my-webapp/foo/index.html I get a 404.
Various parts of the Servlet 3.0 spec would imply that you can create a directory structure under the resources directory and that files in that structure will be served as static resources, however, in practice I am only seeing files directly under the resources directory being served as static resources.
For simplicity sake in testing serving static resources in this way I set up my test case to not include a web.xml or a class annotated as a servlet.
Is this a factor of how the Default servlet is mapping static resources? Do I have to include a web.xml with some mappings which include a * wildcard to handle subdirectories? Have I stumbled on a legit bug?
Thanks,
-Noah