Skip to content Skip to sidebar Skip to footer

Dropwizard: Unable To Serve Static Html

I'm currently working on serving a static html page in Dropwizard at the root path '/'. So far, I've only received an error page stating 'HTTP ERROR 404 Problem accessing /. Reaso

Solution 1:

After couple of modifications to your code, got it to working condition.

  1. AssetBundle path is calculated from project resources folder. Therefore add path relative to that. Here assets directory is located in ${Project Root}/src/main/resources directory

    bootstrap.addBundle(newAssetsBundle("/assets/", "/"));
    
  2. Remove explicit Jersey registry entry. I believe this is inherited from configuration.

    environment.jersey().setUrlPattern("/*"); /*this line should be removed*/

You will need to included dropwizard-assets to your project's dependencies.

For reference, just created a sample project with static assets.

Post a Comment for "Dropwizard: Unable To Serve Static Html"