Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noClassDefFoundError io.ebean.Ebean #145

Open
Flo354 opened this issue Jan 26, 2018 · 9 comments
Open

noClassDefFoundError io.ebean.Ebean #145

Flo354 opened this issue Jan 26, 2018 · 9 comments

Comments

@Flo354
Copy link

Flo354 commented Jan 26, 2018

Hi,

I can't start play 2.6.11 with sbt 0.13.16, scala 2.12.4 and play-ebean 4.1.0.
I get the following stack trace :

CreationException: Unable to create injector, see the following errors:

  1. Error injecting constructor, java.lang.ExceptionInInitializerError
    at play.db.ebean.EbeanDynamicEvolutions.(EbeanDynamicEvolutions.java:35)
    at play.db.ebean.EbeanDynamicEvolutions.class(EbeanDynamicEvolutions.java:32)
    while locating play.db.ebean.EbeanDynamicEvolutions
    at play.db.ebean.EbeanModule.bindings(EbeanModule.java:21):
    Binding(class play.api.db.evolutions.DynamicEvolutions to ConstructionTarget(class play.db.ebean.EbeanDynamicEvolutions) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
    while locating play.api.db.evolutions.DynamicEvolutions
    while locating play.api.db.evolutions.ApplicationEvolutionsProvider
    at play.api.db.evolutions.EvolutionsModule.(EvolutionsModule.scala:20):
    Binding(class play.api.db.evolutions.ApplicationEvolutions to ProviderConstructionTarget(class play.api.db.evolutions.ApplicationEvolutionsProvider) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
    while locating play.api.db.evolutions.ApplicationEvolutions
    Caused by: java.lang.ExceptionInInitializerError
    at io.ebean.EbeanServerFactory.create(EbeanServerFactory.java:72)
    at play.db.ebean.EbeanDynamicEvolutions.lambda$start$3(EbeanDynamicEvolutions.java:49)
    at java.util.HashMap.forEach(HashMap.java:1289)
    at play.db.ebean.EbeanDynamicEvolutions.start(EbeanDynamicEvolutions.java:49)
    at play.db.ebean.EbeanDynamicEvolutions.(EbeanDynamicEvolutions.java:38)
    at play.db.ebean.EbeanDynamicEvolutions$$FastClassByGuice$$52c94231.newInstance()
    at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1019)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1015)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1054)
    at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:409)
    at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:404)
    at play.api.inject.ContextClassLoaderInjector.$anonfun$instanceOf$2(Injector.scala:117)
    at play.api.inject.ContextClassLoaderInjector.withContext(Injector.scala:126)
    at play.api.inject.ContextClassLoaderInjector.instanceOf(Injector.scala:117)
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get$lzycompute(EvolutionsModule.scala:49)
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:49)
    at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:40)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    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.inject.guice.GuiceBuilder.injector(GuiceBuilder.java:221)
    at play.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.java:156)
    at play.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.java:34)
    at play.api.ApplicationLoader$JavaApplicationLoaderAdapter$1.load(ApplicationLoader.scala:87)
    at play.core.server.DevServerStart$$anon$1.$anonfun$reload$3(DevServerStart.scala:174)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:171)
    at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:124)
    at play.core.server.AkkaHttpServer.modelConversion(AkkaHttpServer.scala:183)
    at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:189)
    at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:106)
    at akka.stream.impl.fusing.MapAsync$$anon$24.onPush(Ops.scala:1191)
    at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:512)
    at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:475)
    at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:371)
    at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:584)
    at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:468)
    at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:559)
    at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:741)
    at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:756)
    at akka.actor.Actor.aroundReceive(Actor.scala:517)
    at akka.actor.Actor.aroundReceive$(Actor.scala:515)
    at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:666)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:527)
    at akka.actor.ActorCell.invoke(ActorCell.scala:496)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: DataSource user is null?
    at io.ebean.Ebean$ServerManager.(Ebean.java:166)
    at io.ebean.Ebean$ServerManager.(Ebean.java:126)
    at io.ebean.Ebean.(Ebean.java:120)
    ... 83 more
    Caused by: java.lang.RuntimeException: DataSource user is null?
    at org.avaje.datasource.pool.ConnectionPool.(ConnectionPool.java:204)
    at org.avaje.datasource.core.Factory.createPool(Factory.java:15)
    at io.ebeaninternal.server.core.DefaultContainer.getDataSourceFromConfig(DefaultContainer.java:326)
    at io.ebeaninternal.server.core.DefaultContainer.setDataSource(DefaultContainer.java:281)
    at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:120)
    at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:91)
    at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:46)
    at io.ebean.EbeanServerFactory.create(EbeanServerFactory.java:54)
    at io.ebean.Ebean$ServerManager.getWithCreate(Ebean.java:203)
    at io.ebean.Ebean$ServerManager.(Ebean.java:161)
    ... 85 more
  1. Error injecting constructor, java.lang.NoClassDefFoundError: Could not initialize class io.ebean.Ebean
    at play.db.ebean.EbeanDynamicEvolutions.(EbeanDynamicEvolutions.java:35)
    at play.db.ebean.EbeanDynamicEvolutions.class(EbeanDynamicEvolutions.java:32)
    while locating play.db.ebean.EbeanDynamicEvolutions
    at play.db.ebean.EbeanModule.bindings(EbeanModule.java:21):
    Binding(class play.api.db.evolutions.DynamicEvolutions to ConstructionTarget(class play.db.ebean.EbeanDynamicEvolutions) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
    while locating play.api.db.evolutions.DynamicEvolutions
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.ebean.Ebean
    at io.ebean.EbeanServerFactory.create(EbeanServerFactory.java:72)
    at play.db.ebean.EbeanDynamicEvolutions.lambda$start$3(EbeanDynamicEvolutions.java:49)
    at java.util.HashMap.forEach(HashMap.java:1289)
    at play.db.ebean.EbeanDynamicEvolutions.start(EbeanDynamicEvolutions.java:49)
    at play.db.ebean.EbeanDynamicEvolutions.(EbeanDynamicEvolutions.java:38)
    at play.db.ebean.EbeanDynamicEvolutions$$FastClassByGuice$$52c94231.newInstance()
    at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    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.inject.guice.GuiceBuilder.injector(GuiceBuilder.java:221)
    at play.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.java:156)
    at play.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.java:34)
    at play.api.ApplicationLoader$JavaApplicationLoaderAdapter$1.load(ApplicationLoader.scala:87)
    at play.core.server.DevServerStart$$anon$1.$anonfun$reload$3(DevServerStart.scala:174)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:171)
    at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:124)
    at play.core.server.AkkaHttpServer.modelConversion(AkkaHttpServer.scala:183)
    at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:189)
    at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:106)
    at akka.stream.impl.fusing.MapAsync$$anon$24.onPush(Ops.scala:1191)
    at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:512)
    at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:475)
    at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:371)
    at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:584)
    at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:468)
    at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:559)
    at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:741)
    at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:756)
    at akka.actor.Actor.aroundReceive(Actor.scala:517)
    at akka.actor.Actor.aroundReceive$(Actor.scala:515)
    at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:666)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:527)
    at akka.actor.ActorCell.invoke(ActorCell.scala:496)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

2 errors

There is no error with play-ebean 4.0.6.

@mschoenlaub
Copy link

I have the same problem. Have you found out anything more about it?

@Flo354
Copy link
Author

Flo354 commented Feb 12, 2018

Nope :(

@marcospereira
Copy link
Member

Hi @Flo354,

Could you please provide a sample project that reproduces the error?

Best.

@Flo354
Copy link
Author

Flo354 commented Aug 23, 2018

Hi @marcospereira

I found a solution to my problem, it seems to be related to a wrong statement in the documentation. I wrote it here: #457

I have two databases, db.development and db.production.

While, this page https://www.playframework.com/documentation/2.6.x/JavaEbean tells:
This defines a default Ebean server, using the default data source, which must be properly configured. You can also override the name of the default Ebean server by configuring ebeanconfig.datasource.default property

The property to define is not ebeanconfig.datasource.default but play.ebean.defaultDatasource

Found this here: https://stackoverflow.com/a/31070658

@marcospereira
Copy link
Member

Thank you, @Flo354.

Do you want to submit a PR to fix the docs? The file for that page is here:

https://github.com/playframework/play-ebean/blob/master/docs/manual/working/javaGuide/main/sql/JavaEbean.md

Best.

@jtammen
Copy link

jtammen commented Dec 12, 2018

I am experiencing the same error. Versions used:

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.20")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.1.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.2.2")

I just have just one DB, configured via `db.default.url=mysql://user:pw@localhost/dbname. In DEV mode everything works OK, the error only appears in PROD mode :-/

Did anyone find the root cause of this error?

@joschi
Copy link

joschi commented Mar 19, 2019

The solution proposed by @Flo354 worked in our case, in which we had the same problem.

# https://github.com/playframework/play-ebean/issues/145#issuecomment-415402030
play.ebean.defaultDatasource = "default"
ebeanconfig.datasource.default = "default"

@joschi
Copy link

joschi commented Jul 25, 2019

It turns out that these settings didn't solve the issue.

Right now it's not possible to effectively reproduce the issue or come to a lasting solution. 😞

@mkurz
Copy link
Member

mkurz commented Mar 15, 2024

Hey guys, is this still a problem with newer Play and play-ebean releases?

btw, I think #457 is a duplicate (?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants