can anyone tell me how to view my 404 page. I googled and tried to implement ExceptionMapper<RuntimeException>, but this did not work completely. I am using version 0.8.1
My Exception mapper:
public class RuntimeExceptionMapper implements ExceptionMapper<NotFoundException> {
@Override
public Response toResponse(NotFoundException exception) {
Response defaultResponse = Response.status(Status.OK)
.entity(JsonUtils.getErrorJson("default response"))
.build();
return defaultResponse;
}
}
This only works with the wrong APIs and not with resource calls
My setup:
@Override
public void initialize(Bootstrap<WebConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/webapp", "/", "index.html"));
}
@Override
public void run(WebConfiguration configuration, Environment environment) throws Exception {
environment.jersey().register(RuntimeExceptionMapper.class);
((AbstractServerFactory) configuration.getServerFactory()).setJerseyRootPath("/api/*");
environment.jersey().register(new AuditResource(auditDao));
....
}
Now,
http://localhost:8080/api/rubishgoes through an overridden method ExceptionMapper
http://localhost:8080/rubish.htmldisplays 404 pages by default
How to set up dropwizard to display 404 user page when requesting unknown pages
I referenced this link for the exception linker