Injector fails with hikaricp error

Hi,

I can’t understand why I’ve got this:

play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:

1) Error injecting method, java.lang.NoSuchMethodError: com.zaxxer.hikari.HikariConfig.setInitializationFailTimeout(J)V
  at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:154)
  at play.api.db.DBModule$$anonfun$$lessinit$greater$1.$anonfun$new$1(DBModule.scala:28):
Binding(interface play.api.db.Database qualified with QualifierInstance(@play.db.NamedDatabase(value=default)) to ProviderTarget(play.api.db.NamedDatabaseProvider@385e6299)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$4)

1 error]
        at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:210)
        at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:141)
        at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:296)
        at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:186)
        at akka.stream.impl.fusing.MapAsync$$anon$30.onPush(Ops.scala:1261)
        at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:541)
        at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:423)
        at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:624)
        at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:501)
        at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:599)
Caused by: com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Error injecting method, java.lang.NoSuchMethodError: com.zaxxer.hikari.HikariConfig.setInitializationFailTimeout(J)V
  at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:154)
  at play.api.db.DBModule$$anonfun$$lessinit$greater$1.$anonfun$new$1(DBModule.scala:28):
Binding(interface play.api.db.Database qualified with QualifierInstance(@play.db.NamedDatabase(value=default)) to ProviderTarget(play.api.db.NamedDatabaseProvider@385e6299)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$4)

1 error
        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:543)
        at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:178)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109)
        at com.google.inject.Guice.createInjector(Guice.java:87)
        at com.google.inject.Guice.createInjector(Guice.java:78)
        at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:200)
        at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:155)
        at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
        at play.core.server.DevServerStart$$anon$1.$anonfun$reload$3(DevServerStart.scala:189)
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
Caused by: java.lang.NoSuchMethodError: com.zaxxer.hikari.HikariConfig.setInitializationFailTimeout(J)V
        at play.api.db.HikariCPConfig.toHikariConfig(HikariCPModule.scala:129)
        at play.api.db.HikariCPConnectionPool.$anonfun$create$1(HikariCPModule.scala:57)
        at scala.util.Try$.apply(Try.scala:210)
        at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54)
        at play.api.db.PooledDatabase.createDataSource(Databases.scala:248)
        at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:140)
        at play.api.db.DefaultDatabase.dataSource(Databases.scala:138)
        at play.api.db.DefaultDBApi.$anonfun$initialize$1(DefaultDBApi.scala:72)
        at scala.collection.immutable.List.foreach(List.scala:305)
        at play.api.db.DefaultDBApi.initialize(DefaultDBApi.scala:68)

using play 2.8.0.

Hey @KannarFr,

It looks like you have mixed versions of Play in your project, or something else (maybe play-slick) that is bringing a non-compatible version of HikariCP transitively. If you are using sbt 1.2.8, sbt-dependency-graph can help you to identify from where the old HikariCP dependency is coming from.

Best.

In my case an incorrect version of HikariCP was being pulled in by akka-quartz-scheduler:

com.enragedginger:akka-quartz-scheduler_2.12:1.8.2-akka-2.6.x
  | +-org.quartz-scheduler:quartz:2.3.0
  |   +-com.mchange:c3p0:0.9.5.2
  |   | +-com.mchange:mchange-commons-java:0.2.11
  |   | 
  |   +-com.mchange:mchange-commons-java:0.2.11
  |   +-com.zaxxer:HikariCP-java6:2.3.13
  |   | +-org.slf4j:slf4j-api:1.7.10 (evicted by: 1.7.29)
  |   | +-org.slf4j:slf4j-api:1.7.29
  |   | 
  |   +-org.slf4j:slf4j-api:1.7.29
  |   +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.29)
  |
1 Like

@marcospereira thanks for the plugin, was useful.

@softdevca yes same! I removed the dep and coded my own quartz system.