Open mpgirro opened 6 years ago
I'm facing exactly the same problem. Any progress?
[error] application -
! @7ao995naj - Internal server error, for (GET) [/assets/docs] ->
play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:
1) Error injecting constructor, java.lang.NullPointerException
at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:35)
while locating play.modules.swagger.SwaggerPluginImpl
at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11):
Binding(interface play.modules.swagger.SwaggerPlugin to ConstructionTarget(class play.modules.swagger.SwaggerPluginImpl) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$4)
while locating play.modules.swagger.SwaggerPlugin
1 error]
at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:186)
at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:124)
at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:241)
at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:138)
at akka.stream.impl.fusing.MapAsyncUnordered$$anon$31.onPush(Ops.scala:1318)
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:519)
at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:482)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:378)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:588)
at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:472)
Caused by: com.google.inject.CreationException: Unable to create injector, see the following errors:
1) Error injecting constructor, java.lang.NullPointerException
at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:35)
while locating play.modules.swagger.SwaggerPluginImpl
at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11):
Binding(interface play.modules.swagger.SwaggerPlugin to ConstructionTarget(class play.modules.swagger.SwaggerPluginImpl) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$4)
while locating play.modules.swagger.SwaggerPlugin
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:470)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.Guice.createInjector(Guice.java:99)
at com.google.inject.Guice.createInjector(Guice.java:84)
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:185)
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:137)
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
at play.core.server.DevServerStart$$anon$1.$anonfun$reload$3(DevServerStart.scala:174)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
Caused by: java.lang.NullPointerException: null
at java.io.Reader.<init>(Reader.java:78)
at java.io.InputStreamReader.<init>(InputStreamReader.java:129)
at scala.io.BufferedSource.reader(BufferedSource.scala:26)
at scala.io.BufferedSource.bufferedReader(BufferedSource.scala:27)
at scala.io.BufferedSource.charReader$lzycompute(BufferedSource.scala:37)
at scala.io.BufferedSource.charReader(BufferedSource.scala:35)
at scala.io.BufferedSource.scala$io$BufferedSource$$decachedReader(BufferedSource.scala:64)
at scala.io.BufferedSource.mkString(BufferedSource.scala:93)
at play.modules.swagger.SwaggerPluginImpl.play$modules$swagger$SwaggerPluginImpl$$parseRoutesHelper$1(SwaggerPlugin.scala:122)
at play.modules.swagger.SwaggerPluginImpl$$anonfun$1.applyOrElse(SwaggerPlugin.scala:131)
[error] application -
My conf/routes:
# Include API v1 Routes
-> /api/v1 v1.Routes
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
GET /docs controllers.ApiHelpController.getResources
I renamed the Swagger 'dist' folder to 'docs' and put it into my project 'public' folder.
Added play.modules.enabled += "play.modules.swagger.SwaggerModule"
into my application.conf
Added "io.swagger" %% "swagger-play2" % "1.6.0",
into my build.sbt
We have this same error sometimes (I guess when we change the routes file..).
@romeromfm @gaeljw Can you publish a complete project with this error on github. I will look into it and try to prepare new version of swagger-play.
@mgosk I have created an example project with this error here https://github.com/mpgirro/play2.6-swagger-issue
The project structure builds on the official playframework/play-scala-rest-api-example (2.6.x branch) and applies the steps to add swagger-play
as in my original description at the top of this issue.
Thanks for looking into it!
I am experiencing a NullPointerException upon startup in Play 2.6 with
swagger-play2
1.6.0. The complete error message and strack trace is:The cause seems to be related to the
routes
file. After studyingSwaggerPlugin.scala
, it appears to me that swagger-play2 does not read the content of the defaultconfig/routes
file, and therefore experiences this Nullpointer.I'm merely using the standard setup for this library:
build.sbt
:"io.swagger" %% "swagger-play2" % "1.6.0"
application.conf
:play.modules.enabled += "play.modules.swagger.SwaggerModule"
swagger-ui-dist
resources placed under/public/swagger/
conf/routes
:It this a bug or does anybody have an explication why this happens?