Bug in AssetsBundle (v. 0.7.0)

109 views
Skip to first unread message

Rob

unread,
May 20, 2014, 6:52:49 PM5/20/14
to dropwiz...@googlegroups.com
I've been trying to get AssetsBundle to load assets from a shaded JAR in Dropwizard 0.7.0 with no success. Here's my code:

In the initialize method of the Application class, I have the following line of code:

bootstrap.addBundle(new AssetsBundle("/assets/favicon.ico", "/favicon.ico"));

The favicon.ico file is located in: src/main/resources/assets/favicon.ico. I have verified that the JAR contains the file in the correct location in the JAR (i.e. from root of JAR: /assets/favicon.ico). 

Requesting http://127.0.0.1:8080/favicon.ico results in a 404 (although it's a bit different in that Jetty returns its 404 error page - unlike if I request something I know does not exist, in which case just a 404 response is returned).

For now I am using the Bazaarvoice ConfiguredAssetsBundle instead, which works like a charm, but I'd love to know if I was not using AssetsBundle correctly, or whether this is indeed a bug.



o...@fleaflicker.com

unread,
May 21, 2014, 12:08:08 PM5/21/14
to dropwiz...@googlegroups.com
I think you're misusing AssetsBundle. It's expecting paths directories, not a files.

This should work, but it will also serve all the other files in your assets directory from the root path:

new AssetsBundle("/assets", "/")

Rob

unread,
May 21, 2014, 1:03:37 PM5/21/14
to dropwiz...@googlegroups.com
I just tried switching out my line of code for your suggestion. Now when I request 127.0.0.1:8080/favicon.ico, I get a 404 response, but it's a different, in that Jetty does not also return its default 404 error page. 

Oddly enough, if I set: environment.jersey().setUrlPattern("/foo/*"), I get the 404 response but it does also return Jetty's default 404 page.  
Reply all
Reply to author
Forward
0 new messages