play-ebean icon indicating copy to clipboard operation
play-ebean copied to clipboard

Build production failing if I have application.properties configuration

Open almothafar opened this issue 4 years ago • 2 comments

I don't have this issue with another plugin: https://github.com/payintech/play-ebean and it is working fine, except that plugin got an issue (https://github.com/payintech/play-ebean/issues/15) that making me try this one and this not working as well with different kind of issues.

I got the following application.properties inside conf folder:

#https://github.com/ebean-orm/ebean/blob/master/CONFIGURATION.md
ebean.default.databasePlatformName=sqlserver17
ebean.default.idType=IDENTITY
ebean.default.allQuotedIdentifiers=true

When I try to do production build I get the following issue:

[info] Done compiling.
[error] java.lang.RuntimeException: com.typesafe.config.ConfigException$WrongType: application.properties @ file:/app/conf/application.properties: default has type OBJECT rather than LIST
[error] 	at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:163)
[error] 	at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:174)
[error] 	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:188)
[error] 	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:193)
[error] 	at com.typesafe.config.impl.SimpleConfig.getList(SimpleConfig.java:262)
[error] 	at com.typesafe.config.impl.SimpleConfig.getHomogeneousUnwrappedList(SimpleConfig.java:348)
[error] 	at com.typesafe.config.impl.SimpleConfig.getStringList(SimpleConfig.java:406)
[error] 	at play.db.ebean.EbeanParsedConfig.lambda$parseFromConfig$0(EbeanParsedConfig.java:58)
[error] 	at java.base/java.util.Map.forEach(Map.java:661)
[error] 	at play.db.ebean.EbeanParsedConfig.parseFromConfig(EbeanParsedConfig.java:52)
[error] 	at play.db.ebean.ModelsConfigLoader.apply(ModelsConfigLoader.java:29)
[error] 	at play.db.ebean.ModelsConfigLoader.apply(ModelsConfigLoader.java:22)
[error] 	at play.ebean.sbt.PlayEbean$.$anonfun$configuredEbeanModels$4(PlayEbean.scala:149)
[error] 	at play.ebean.sbt.PlayEbean$.withClassLoader$1(PlayEbean.scala:126)
[error] 	at play.ebean.sbt.PlayEbean$.$anonfun$configuredEbeanModels$1(PlayEbean.scala:146)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] 	at sbt.Execute.work(Execute.scala:290)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] 	at java.base/java.lang.Thread.run(Thread.java:834)
[error] (Compile / playEbeanModels) com.typesafe.config.ConfigException$WrongType: application.properties @ file:/app/conf/application.properties: default has type OBJECT rather than LIST
[error] Total time: 43 s, completed Feb 17, 2021, 10:09:04 AM
The command '/bin/sh -c sbt clean update compile dist' returned a non-zero code: 1

What exactly this problem, it is not saying what exactly the broken config key that expecting LIST!

I'm using version 6.0.0:

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "6.0.0")

almothafar avatar Feb 17 '21 10:02 almothafar

@almothafar I just released play-ebean 6.2.0-RC4, please have a look at the release notes how to upgrade: https://github.com/playframework/play-ebean/releases/tag/6.2.0-RC4. Please let me know if this problem you reported here is fixed with that release, thanks!

mkurz avatar Jan 28 '22 22:01 mkurz

The problem here is that the typesafe config loads conf/application.properties on top of application.conf, meaning Play's app config will also contain all the ebean.* configs (databasePlatformName, idType,...). But the application.properties file here is only meant for ebean, not for Play... As long as ebean's config was called ebean.properties (which is deprecated) there was no problem of course because typesafe config doesn't care about such a file. But now when it loads the application.properties it tries to iterate over the ebean.* keys which then fails: https://github.com/playframework/play-ebean/blob/6e706104e9cbdf71d4b258de043a8a714073b1d8/play-ebean/src/main/java/play/db/ebean/EbeanParsedConfig.java#L43-L65

The immediate solution is to just use (and recommend) application.yaml instead of application.properties: https://ebean.io/docs/intro/configuration/

Long term we coud just switch Play's default ebean config key to be play.ebean instead of just ebean: https://github.com/playframework/play-ebean/blob/6e706104e9cbdf71d4b258de043a8a714073b1d8/play-ebean/src/main/resources/reference.conf#L8

mkurz avatar Mar 06 '23 17:03 mkurz