Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropwizard 0.8 and Jetty fail return 404 on resources

I am trying to hook up a dropwizard 0.8.* application, and I have used a hello world starter example.

The code is left untouched and the application starts-up normally.

Though when I try to access the path assigned to the hello world GET request, the browser returns a :

HTTP ERROR 404

Problem accessing /hello-world. Reason:

    Not Found

This is kinda strange since the app logs say otherwise and return 200 for that request:

0:0:0:0:0:0:0:1 - - [15/Sep/2015:07:33:58 +0000] "GET /hello-world HTTP/1.1" 200 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36" 0

Am I missing anything in terms of configuration or else ? I am running under OSX and google Chrome.

Adding more information I have tried two different hello-world examples and both fail. On top with spring boot and also akka-http I have no problems.

like image 207
Lucian Enache Avatar asked Sep 15 '15 07:09

Lucian Enache


People also ask

How do I return from Dropwizard 404?

The simplest way is to return an Optional<MyObject> . Dropwizard will automatically throw a 404 when your result is Optional. absent() or Optional.

What is Jetty Dropwizard?

Jetty: You would require HTTP for running a web application. Dropwizard embeds the Jetty servlet container for running web applications. Instead of deploying your applications to an application server or web server, Dropwizard defines a main method that invokes the Jetty server as a standalone process.


1 Answers

I had the same issue,

While starting the server it says "MutableServletContextHandler@4b2a30d{/application,null,AVAILABLE}"

so try /application/hello-world,

It worked for me. (Credit to my friend who helped me :) )

http://tips.tutorialhorizon.com/2015/10/03/dropwizard-0-8-and-jetty-fail-return-404-on-resources/

like image 113
Sumit Jain Avatar answered Nov 15 '22 17:11

Sumit Jain