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

Build production failing if I have application.properties configuration #212

Open
almothafar opened this issue Feb 17, 2021 · 2 comments
Open

Comments

@almothafar
Copy link

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 (payintech#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")
@mkurz
Copy link
Member

mkurz commented Jan 28, 2022

@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
Copy link
Member

mkurz commented Mar 6, 2023

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:

public static EbeanParsedConfig parseFromConfig(Config config) {
Config playEbeanConfig = config.getConfig("play.ebean");
String defaultDatasource = playEbeanConfig.getString("defaultDatasource");
String ebeanConfigKey = playEbeanConfig.getString("config");
Map<String, List<String>> datasourceModels = new HashMap<>();
if (config.hasPath(ebeanConfigKey)) {
Config ebeanConfig = config.getConfig(ebeanConfigKey);
ebeanConfig.root().forEach((key, raw) -> {
List<String> models;
if (raw.valueType() == ConfigValueType.STRING) {
// Support legacy comma separated string
models = Arrays.asList(((String) raw.unwrapped()).split(","));
} else {
models = ebeanConfig.getStringList(key);
}
datasourceModels.put(key, models);
});
}
return new EbeanParsedConfig(defaultDatasource, datasourceModels);
}

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:

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

No branches or pull requests

2 participants