dwickern / swagger-play

Swagger API docs for Play Framework
Apache License 2.0
22 stars 4 forks source link

NoSuchMethodError with play 2.8.8 #4

Closed Hayanesh closed 3 years ago

Hayanesh commented 3 years ago

Hi, I recently upgraded my play framework project from version 2.7 to 2.8. Previously I was using this library ("io.swagger" %% "swagger-play2" % "1.7.1") for generating swagger documentations. This one which I used is not compatible with play 2.8. While looking for an alternative I found your library. I have replaced the old dependency with ("com.github.dwickern" %% "swagger-play2.8" % "3.0.0"). Post which when I hit the swagger endpoint I'm getting the following error.

After a short googling, I found that play 2.8 uses jackson version 2.10 in which the getType(TypeBindings bogus) method got removed. Please help me resolve this issue.

Related Link: swagger issue [jackson javadoc](https://fasterxml.github.io/jackson-databind/javadoc/2.8/com/fasterxml/jackson/databind/introspect/Annotated.html#getType())

Play Version : 2.8.8 Scala Version : 2.13.5 Java Version : openjdk 14.0.2 2020-07-14

Application log play.api.PlayException: Execution exception[[CompletionException: java.lang.RuntimeException: java.lang.NoSuchMethodError: 'com.fasterxml.jackson.databind.JavaType com.fasterxml.jackson.databind.introspect.AnnotatedMember.getType(com.fasterxml.jackson.databind.type.TypeBindings)']] at play.api.http.HttpErrorHandlerExceptions$.$anonfun$convertToPlayException$3(HttpErrorHandler.scala:388) at scala.Option.getOrElse(Option.scala:201) at play.api.http.HttpErrorHandlerExceptions$.convertToPlayException(HttpErrorHandler.scala:388) at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:373) at play.api.http.HttpErrorHandlerExceptions.throwableToUsefulException(HttpErrorHandler.scala) at play.http.JsonHttpErrorHandler.throwableToUsefulException(JsonHttpErrorHandler.java:112) at play.http.JsonHttpErrorHandler.onServerError(JsonHttpErrorHandler.java:67) at play.http.PreferredMediaTypeHttpErrorHandler.onServerError(PreferredMediaTypeHttpErrorHandler.java:54) at play.core.j.JavaHttpErrorHandlerAdapter.onServerError(JavaHttpErrorHandlerAdapter.scala:32) at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:430) Caused by: java.util.concurrent.CompletionException: java.lang.RuntimeException: java.lang.NoSuchMethodError: 'com.fasterxml.jackson.databind.JavaType com.fasterxml.jackson.databind.introspect.AnnotatedMember.getType(com.fasterxml.jackson.databind.type.TypeBindings)' at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331) at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:346) at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:632) at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2152) at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:29) at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:26) at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:448) at scala.concurrent.ExecutionContext$parasitic$.execute(ExecutionContext.scala:222) at scala.concurrent.impl.Promise$Transformation.submitWithValue(Promise.scala:393) Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: 'com.fasterxml.jackson.databind.JavaType com.fasterxml.jackson.databind.introspect.AnnotatedMember.getType(com.fasterxml.jackson.databind.type.TypeBindings)' at play.api.mvc.ActionBuilder$$anon$9.apply(Action.scala:384) at play.api.mvc.Action.$anonfun$apply$4(Action.scala:82) at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$4(Accumulator.scala:168) at scala.util.Try$.apply(Try.scala:210) at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$3(Accumulator.scala:168) at akka.stream.impl.Transform.apply(TraversalBuilder.scala:159) at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:522) at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:448) at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:440) at akka.stream.scaladsl.RunnableGraph.run(Flow.scala:744) Caused by: java.lang.NoSuchMethodError: 'com.fasterxml.jackson.databind.JavaType com.fasterxml.jackson.databind.introspect.AnnotatedMember.getType(com.fasterxml.jackson.databind.type.TypeBindings)' at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:425) at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:203) at io.swagger.scala.converter.SwaggerScalaModelConverter.resolve(SwaggerScalaModelConverter.scala:90) at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:103) at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:257) at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:203) at io.swagger.scala.converter.SwaggerScalaModelConverter.resolve(SwaggerScalaModelConverter.scala:90) at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:103) at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:175) at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:126)

dwickern commented 3 years ago

Looks like Play Framework's 2.8.8 minor release upgraded its Jackson dependency from 2.10 to 2.11.

playframework jackson swagger-core
2.7 2.9.x 1.5.24
2.8.0-2.8.7 2.10.x 1.6.0-1.6.1
2.8.8 2.11.x 1.6.2

Does it work with swagger-core 1.6.2?

libraryDependencies += "io.swagger" % "swagger-core" % "1.6.2"
Hayanesh commented 3 years ago

Yes. It works now. Thanks a lot!

dwickern commented 3 years ago

👍 I updated the readme