You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm trying to use swagger-play, but reached this exception when adding classOf, if I remove 'response' it does return a JSON.
I suspect this might be because of jackson incompatibility. There's a another lib I use which has jackson: 2.14 as transitive dependency. As I understand swagger-play would only support up to jackson 2.10.x.
Is there a way to overcome this?
@ApiResponses(Array(
new ApiResponse(
code = 200,
message = "The name of the pet",
response = classOf[String]
),
))
The error:
[error] p.c.s.n.PlayRequestHandler - Cannot invoke the action
java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class io.swagger.converter.ModelConverters
at play.api.mvc.ActionBuilder$$anon$10.apply(Action.scala:424)
at play.api.mvc.Action.$anonfun$apply$2(Action.scala:95)
at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$4(Accumulator.scala:181)
at scala.util.Try$.apply(Try.scala:213)
at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$3(Accumulator.scala:181)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at play.api.libs.streams.StrictAccumulator.run(Accumulator.scala:216)
at play.api.libs.streams.FlattenedAccumulator.$anonfun$run$2(Accumulator.scala:240)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.swagger.converter.ModelConverters
at play.modules.swagger.PlayReader.parseMethod(PlayReader.java:566)
at play.modules.swagger.PlayReader.read(PlayReader.java:147)
at play.modules.swagger.PlayReader.read(PlayReader.java:76)
at play.modules.swagger.PlayReader.read(PlayReader.java:70)
at play.modules.swagger.ApiListingCache.$anonfun$listing$1(ApiListingCache.scala:17)
at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:86)
at play.modules.swagger.ApiListingCache.listing(ApiListingCache.scala:13)
at controllers.SwaggerBaseApiController.getResourceListing(ApiHelpController.scala:69)
at controllers.SwaggerBaseApiController.getResourceListing$(ApiHelpController.scala:55)
at controllers.ApiHelpController.getResourceListing(ApiHelpController.scala:30)
[error] application -
! @83odeke85 - Internal server error, for (GET) [/swagger.json] ->
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class io.swagger.converter.ModelConverters]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:344)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:263)
at play.core.server.netty.PlayRequestHandler$$anonfun$play$core$server$netty$PlayRequestHandler$$handleAction$1.applyOrElse(PlayRequestHandler.scala:303)
at play.core.server.netty.PlayRequestHandler$$anonfun$play$core$server$netty$PlayRequestHandler$$handleAction$1.applyOrElse(PlayRequestHandler.scala:300)
at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:417)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:70)
at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:72)
at scala.concurrent.impl.Promise$DefaultPromise.$anonfun$tryComplete$1(Promise.scala:288)
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class io.swagger.converter.ModelConverters
at play.api.mvc.ActionBuilder$$anon$10.apply(Action.scala:424)
at play.api.mvc.Action.$anonfun$apply$2(Action.scala:95)
at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$4(Accumulator.scala:181)
at scala.util.Try$.apply(Try.scala:213)
at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$3(Accumulator.scala:181)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
at play.api.libs.streams.StrictAccumulator.run(Accumulator.scala:216)
at play.api.libs.streams.FlattenedAccumulator.$anonfun$run$2(Accumulator.scala:240)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.swagger.converter.ModelConverters
at play.modules.swagger.PlayReader.parseMethod(PlayReader.java:566)
at play.modules.swagger.PlayReader.read(PlayReader.java:147)
at play.modules.swagger.PlayReader.read(PlayReader.java:76)
at play.modules.swagger.PlayReader.read(PlayReader.java:70)
at play.modules.swagger.ApiListingCache.$anonfun$listing$1(ApiListingCache.scala:17)
at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:86)
at play.modules.swagger.ApiListingCache.listing(ApiListingCache.scala:13)
at controllers.SwaggerBaseApiController.getResourceListing(ApiHelpController.scala:69)
at controllers.SwaggerBaseApiController.getResourceListing$(ApiHelpController.scala:55)
at controllers.ApiHelpController.getResourceListing(ApiHelpController.scala:30)
The text was updated successfully, but these errors were encountered:
So it failed to initialize io.swagger.converter.ModelConverters. The class is there on the classpath but the class constructor threw an exception. It would help if you can find the exception which occurred, maybe using your debugger.
Your third-party library pulled in jackson-databind 2.14.2 but you still have other Jackson libs on version 2.9. This is a problem. You shouldn't mix different versions.
Here are some things you can do:
Downgrade to Jackson 2.9 by excluding the Jackson 2.14 dependency. This might cause an issue for the third-party library. Also you don't really want to be on Jackson 2.9...
Upgrade all Jackson libs to 2.14. This might cause an issue for Play and/or Swagger.
Find an alternative to your third-party lib
Upgrade your Play version, use a recent version of Jackson, then introduce swagger-play
Swagger-play doesn't care about the Jackson version, but Play Framework and swagger-core both do. See the compatibility table in the README.
Hi,
i'm trying to use swagger-play, but reached this exception when adding
classOf
, if I remove 'response' it does return a JSON.I suspect this might be because of jackson incompatibility. There's a another lib I use which has jackson: 2.14 as transitive dependency. As I understand swagger-play would only support up to jackson 2.10.x.
Is there a way to overcome this?
Versions:
My code
The error:
The text was updated successfully, but these errors were encountered: