akka/akka-http

Error when loading static content using AKKA-HTTP Java

オープン

#2,247 opened on 2018/10/08

 (17 件のコメント) (0 件のリアクション) (0 人の担当者)Scala (598 件のフォーク)batch import
1 - triagedhackathonhelp wantedt:docst:routingt:server

Repository metrics

Stars
 (1,311 個のスター)
PR merge metrics
 (平均マージ 1d 10h) (30d で 2 merged PRs)

説明

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]

コントリビューターガイド