Skip to content

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

Closed

Description

@almothafar

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")

Activity

  1. mkurz commented on Jan 28, 2022

    @mkurz
    Member

    @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!

  2. mkurz commented on Mar 6, 2023

    @mkurz
    Member

    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:

  3. mkurz commented on Oct 8, 2026

    @mkurz
    Member

    This got fixed by

    which will be part of the next releases. Here's what was going on, and how to configure this:

    Cause

    Besides conf/application.conf, Play also loads conf/application.properties into its configuration. That's the same file Ebean reads its own settings from (Ebean doesn't read application.conf). Play Ebean reads the lists of models from ebean.<server> in Play's configuration, and took every entry below ebean. for such a list. So with the application.properties above, ebean.default was an object (databasePlatformName, idType, allQuotedIdentifiers) instead of a list of models, and Play Ebean failed with default has type OBJECT rather than LIST. That happened in the sbt plugin when loading the models to enhance, as in the stack trace above, and at runtime as well. Global Ebean settings like ebean.migration.run=false had the same effect.

    What changed

    Play Ebean now only uses strings and lists below ebean. as lists of models, and ignores everything else, like these ebean.default.* settings.

    How to configure it

    Keep the list of models in conf/application.conf:

    ebean.default = ["models.*"]
    

    and Ebean's own settings in conf/application.properties:

    ebean.default.databasePlatformName=sqlserver17
    ebean.default.idType=IDENTITY
    ebean.default.allQuotedIdentifiers=true

    In Play's configuration, application.conf takes precedence over application.properties, so Play Ebean gets the list of models from there, while Ebean reads its settings from application.properties itself.

    Even better, use conf/application.yaml for Ebean's settings, which only Ebean reads, so they don't end up in Play's configuration at all. That's also the place for settings directly below ebean., like ebean.dumpMetricsOnShutdown=true: as all values in application.properties are strings, Play Ebean takes such a setting for a list of models, of an Ebean server without a database, which it then skips.

    With older releases, you can avoid the collision by moving Play Ebean's lists of models to a different key:

    play.ebean.config = "ebeanModels"
    ebeanModels.default = ["models.*"]
    

    The docs now explain where Ebean's own settings go.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions