Error when loading static content using AKKA-HTTP Java
#2247 aperta il 8 ott 2018
Metriche repository
- Star
- (1311 stelle)
- Metriche merge PR
- (Merge medio 1g 10h) (2 PR mergiate in 30 g)
Descrizione
I'm trying out AKKA-Http in Java for the first time(akka-http_2.12 v 10.1.5, akka-stream_2.12 v 2.5.17), but can't seem to load static content for swagger UI. I've added the routes below and able to reach the json and yaml swagger endpoints via http://localhost:8080/api-docs/swagger.json and http://localhost:8080/api-docs/swagger.yaml However, the swagger UI endpoint i.e http://localhost:8080/swagger returns with 'There was an internal server error.' even though I have swagger-ui directory under src/main/resources folder. I've inspected the logs and don't quite understand what is happening..seems like a bug in getFromResource and getFromResourceDirectory functions. Similar issue was reported earlier
Route createRoute() {
return route(
path(PathMatchers.segment(generator.apiDocsPath()).slash("swagger.yaml"),
() -> get(() -> complete(generator.generateSwaggerYaml()))),
path(PathMatchers.segment(generator.apiDocsPath()).slash("swagger.json"),
() -> get(() -> complete(generator.generateSwaggerJson()))),
path("swagger", () -> route (
getFromResource("swagger-ui/index.html"),
getFromResourceDirectory("swagger-ui")
)
)
);
}
akka-spring-docker-system | 2018-10-06 08:27:11.292 ERROR 9 --- [lt-dispatcher-8] akka.actor.ActorSystemImpl : Error during processing of request: 'java.lang.NullPointerException (No error message supplied)'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
akka-spring-docker-system |
akka-spring-docker-system | java.lang.NullPointerException: null
akka-spring-docker-system | at akka.http.scaladsl.server.directives.FileAndResourceDirectives$ResourceFile$.apply(FileAndResourceDirectives.scala:286) ~[akka-http_2.12-10.1.5.jar!/:10.1.5]
akka-spring-docker-system | at akka.http.scaladsl.server.directives.FileAndResourceDirectives.$anonfun$getFromResource$2(FileAndResourceDirectives.scala:106) ~[akka-http_2.12-10.1.5.jar!/:10.1.5]
akka-spring-docker-system | at scala.Option.flatMap(Option.scala:171) ~[scala-library-2.12.4.jar!/:na]
akka-spring-docker-system | at akka.http.scaladsl.server.directives.FileAndResourceDirectives.$anonfun$getFromResource$1(FileAndResourceDirectives.scala:106) ~[akka-http_2.12-10.1.5.jar!/:10.1.5]