Skip to content

"docStore has type OBJECT rather than LIST" error when Elastic configuration is in application.conf #104

Closed

Description

@cpoissonnier

Hi,

When I add these lines to application.conf :

ebean.docstore.url="http://127.0.0.1:9200"
ebean.docstore.active=true
ebean.docstore.generateMapping=false
ebean.docstore.dropCreate=false
ebean.docstore.create=false

I have the following error :
play/conf/application.conf: 26: docStore has type OBJECT rather than LIST

Activity

  1. changed the title [-]"docStore has type OBJECT rather than LIST" when Elastic configuration in application.conf[/-] [+]"docStore has type OBJECT rather than LIST" when Elastic configuration is in application.conf[/+] on Nov 10, 2016
  2. changed the title [-]"docStore has type OBJECT rather than LIST" when Elastic configuration is in application.conf[/-] [+]"docStore has type OBJECT rather than LIST" error when Elastic configuration is in application.conf[/+] on Nov 10, 2016
  3. cpoissonnier commented on Nov 10, 2016

    @cpoissonnier
    Author

    I managed to make it work thanks to the ServerConfigStartup, by adding :

    package models;
    
    import com.avaje.ebean.config.ServerConfig;
    import com.avaje.ebean.event.ServerConfigStartup;
    
    public class MyServerConfigStartup implements ServerConfigStartup {
        public void onStart(ServerConfig serverConfig) {
            serverConfig.getDocStoreConfig().setUrl("http://localhost:9200");
            serverConfig.getDocStoreConfig().setActive(true);
            serverConfig.getDocStoreConfig().setGenerateMapping(false);
            serverConfig.getDocStoreConfig().setDropCreate(false);
            serverConfig.getDocStoreConfig().setCreate(false);
            serverConfig.getDocStoreConfig().setPathToResources("conf");
        }
    }
    
  4. marcospereira commented on Nov 29, 2016

    @marcospereira
    Member

    Problem is here:

    if (raw.valueType() == ConfigValueType.STRING) {
    // Support legacy comma separated string
    models = Arrays.asList(((String) raw.unwrapped()).split(","));
    } else {
    models = ebeanConfig.getStringList(key);
    }

    This is just accepting/parsing String and List configurations.

  5. thibaultmeyer commented on Nov 29, 2016

    @thibaultmeyer
    Contributor

    To use DocStore, You have to put these lines on conf/ebean.properties. The file application.conf is only used to configure datasource and model location (for enhancement and register classes with Ebean server).

  6. cpoissonnier commented on Dec 2, 2016

    @cpoissonnier
    Author

    I could, but I would have to put all ebean configuration in this file (I tried to mix configuration between the ebean.properties and application.conf, but it doesn't work) and the way I deal with different environnement doesn't really allow that. A fix would be more than welcome :)

  7. thibaultmeyer commented on Dec 2, 2016

    @thibaultmeyer
    Contributor

    I see, it make sense, something like that (see below) could be a good approach to handle configuration of all Ebean functionalities.

    application.conf

    ebean {
    
        servers {
            default {
                enhancement = ["models.*"]
    
                docstore {
                    url = "http://127.0.0.1:9200"
                    active = true
                    generateMapping = false
                    dropCreate = false
                    create = false
                }
            }
        }
    
        querybean {
            # Configure type safe queries (http://ebean-orm.github.io/docs/query/typesafe)
            ...
        }
    
        encryption {
            # Configure encryption key manager to use for fields annotated with @Encrypted
            encryptKeyManager = "com.zero_x_baadf00d.ebean.encryption.StandardEncryptKeyManager"
        }
    }
    
  8. thibaultmeyer commented on Dec 2, 2016

    @thibaultmeyer
    Contributor

    ...of course it doesn't work. It's an example of what play-ebean configuration could looks like in the future. I just said "could be a good approach to handle configuration of all Ebean functionalities.".

  9. cpoissonnier commented on Dec 2, 2016

    @cpoissonnier
    Author

    My bad !

    That would be perfect

  10. thibaultmeyer commented on Dec 2, 2016

    @thibaultmeyer
    Contributor

    I can propose a PR this weekend or next weekend... I don't promise all configuration keys will be implemented, but the docstore related keys should working.

  11. thibaultmeyer commented on Dec 10, 2016

    @thibaultmeyer
    Contributor

    @cpoissonnier

    I have rewritted so many files, not sure it will be merged in this project. So we are published our version under our organization.

    in your project/plugins.sbt file, you can override sbt-play-ebean with :

    addSbtPlugin("com.payintech" % "sbt-play-ebean" % "16.12")
    

    And use this application.conf

    # Ebean
    # ~~~~~
    ebean {
      servers {
    
        # You can declare as many servers as you want.
        # By convention, the default server is named `default`
        default {
    
          # Locations of the classes to enhance
          enhancement = ["models.*"]
    
          # Extra server settings
          settings {
    
            # Set to true if this server is Document store only
            onlyUseDocStore = false
    
            # Encryption key manager to use for fields annotated with @Encrypted
            #encryptKeyManager = "com.zero_x_baadf00d.ebean.encryption.StandardEncryptKeyManager"
          }
    
          # Document store
          docstore {
    
            # URL of the ElasticSearch server to use
            url = "http://127.0.0.1:9200"
    
            # Enable document store integration
            active = true
    
            # Set the relative file system path to resources when generating mapping files
            pathToResources = "conf"
    
            # Generate mapping files for each index and these will by default be
            # generated into ${pathToResources} under "elastic-mapping"
            generateMapping = false
    
            # Drop and re-create all indexes
            dropCreate = false
    
            # Create only indexes that have not already been defined
            create = false
          }
        }
      }
    }
    
  12. cpoissonnier commented on Dec 10, 2016

    @cpoissonnier
    Author

    Great ! Thank you so much, I'll try this monday !

  13. ethereal-sandeep commented on Dec 19, 2016

    @ethereal-sandeep

    @cpoissonnier I tried this plugin addSbtPlugin("com.payintech" % "sbt-play-ebean" % "16.12"
    & still got this error
    /application.conf:** 87-90: docstore has type OBJECT rather than LIST]

    Anyone else who is able to run this successfully...please share the config format.

  14. thibaultmeyer commented on Dec 19, 2016

    @thibaultmeyer
    Contributor

    @ethereal-sandeep have you upgraded your application.conf file ? If you have in develop mode, think to restart server after editing project/plugins.sbt.

    # Ebean
    # ~~~~~
    ebean {
      servers {
    
        # You can declare as many servers as you want.
        # By convention, the default server is named `default`
        default {
    
          # Locations of the classes to enhance
          enhancement = ["models.*"]
    
          # Extra server settings
          settings {
    
            # Set to true if this server is Document store only
            onlyUseDocStore = false
    
            # Encryption key manager to use for fields annotated with @Encrypted
            #encryptKeyManager = "com.zero_x_baadf00d.ebean.encryption.StandardEncryptKeyManager"
          }
    
          # Document store
          docstore {
    
            # URL of the ElasticSearch server to use
            url = "http://127.0.0.1:9200"
    
            # Enable document store integration
            active = true
    
            # Set the relative file system path to resources when generating mapping files
            pathToResources = "conf"
    
            # Generate mapping files for each index and these will by default be
            # generated into ${pathToResources} under "elastic-mapping"
            generateMapping = false
    
            # Drop and re-create all indexes
            dropCreate = false
    
            # Create only indexes that have not already been defined
            create = false
          }
        }
      }
    }
    

    @ethereal-sandeep Could copy / past your application.conf (gist) ? have you try to clean ivy cache ?

  15. 12 remaining items

  16. cpoissonnier commented on Dec 21, 2016

    @cpoissonnier
    Author
  17. ethereal-sandeep commented on Dec 22, 2016

    @ethereal-sandeep

    Guys, i know this must have started irritating you all but bear with me for a while. @cpoissonnier i added the settings and also clears ivy2/cache and tried a fresh compile..got this in return.

    java.lang.RuntimeException: com.typesafe.config.ConfigException$WrongType: application.conf @ file:/home/user/projects/server/conf/application.conf: 86-93: servers has type OBJECT rather than LIST
    	at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:159)
    	at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170)
    	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184)
    	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
    	at com.typesafe.config.impl.SimpleConfig.getList(SimpleConfig.java:252)
    	at com.typesafe.config.impl.SimpleConfig.getHomogeneousUnwrappedList(SimpleConfig.java:323)
    	at com.typesafe.config.impl.SimpleConfig.getStringList(SimpleConfig.java:381)
    	at play.db.ebean.EbeanParsedConfig.lambda$parseFromConfig$0(EbeanParsedConfig.java:68)
    	at java.util.Map.forEach(Map.java:630)
    	at play.db.ebean.EbeanParsedConfig.parseFromConfig(EbeanParsedConfig.java:62)
    	at play.db.ebean.ModelsConfigLoader.apply(ModelsConfigLoader.java:28)
    	at play.db.ebean.ModelsConfigLoader.apply(ModelsConfigLoader.java:21)
    	at play.ebean.sbt.PlayEbean$$anonfun$configuredEbeanModels$1$$anonfun$apply$1.apply(PlayEbean.scala:133)
    	at play.ebean.sbt.PlayEbean$$anonfun$configuredEbeanModels$1$$anonfun$apply$1.apply(PlayEbean.scala:130)
    	at play.ebean.sbt.PlayEbean$$anonfun$configuredEbeanModels$1.withClassLoader$1(PlayEbean.scala:109)
    	at play.ebean.sbt.PlayEbean$$anonfun$configuredEbeanModels$1.apply(PlayEbean.scala:130)
    	at play.ebean.sbt.PlayEbean$$anonfun$configuredEbeanModels$1.apply(PlayEbean.scala:98)
    	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    	at sbt.std.Transform$$anon$4.work(System.scala:63)
    	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    	at sbt.Execute.work(Execute.scala:237)
    	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    [error] (compile:playEbeanModels) com.typesafe.config.ConfigException$WrongType: application.conf @ file:/home/user/projects/server/conf/application.conf: 86-93: servers has type OBJECT rather than LIST
    [error] application - 
    
    ! @72ejhm9ge - Internal server error, for (POST) [/test] ->
     
    play.sbt.PlayExceptions$UnexpectedException: Unexpected exception[RuntimeException: com.typesafe.config.ConfigException$WrongType: application.conf @ file:/home/user/projects/server/conf/application.conf: 86-93: servers has type OBJECT rather than LIST]
    	at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:51)
    	at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44)
    	at scala.Option.map(Option.scala:145)
    	at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:44)
    	at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:40)
    	at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
    	at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
    	at scala.util.Either$LeftProjection.map(Either.scala:377)
    	at play.sbt.run.PlayReload$.compile(PlayReload.scala:17)
    	at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$2.apply(PlayRun.scala:61)
    Caused by: java.lang.RuntimeException: com.typesafe.config.ConfigException$WrongType: application.conf @ file:/home/user/projects/server/conf/application.conf: 86-93: servers has type OBJECT rather than LIST
    	at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:159)
    	at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170)
    	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184)
    	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
    	at com.typesafe.config.impl.SimpleConfig.getList(SimpleConfig.java:252)
    	at com.typesafe.config.impl.SimpleConfig.getHomogeneousUnwrappedList(SimpleConfig.java:323)
    	at com.typesafe.config.impl.SimpleConfig.getStringList(SimpleConfig.java:381)
    	at play.db.ebean.EbeanParsedConfig.lambda$parseFromConfig$0(EbeanParsedConfig.java:68)
    	at java.util.Map.forEach(Map.java:630)
    	at play.db.ebean.EbeanParsedConfig.parseFromConfig(EbeanParsedConfig.java:62)
    
    

    my application.conf

    # Ebean configuration
    # ~~~~~
    # You can declare as many Ebean servers as you want.
    # By convention, the default server is named `default`
    #
    #
    ebean.servers.default.enhancement=["models.*"] #Must be a LIST
    # Ebean elastic search  
    ebean.servers.default.docstore.url="http://127.0.0.1:9200"
    ebean.servers.default.docstore.active=true
    ebean.servers.default.docstore.generateMapping=false
    ebean.servers.default.docstore.dropCreate=false
    ebean.servers.default.docstore.create=true
    ebean.servers.default.docstore.pathToResources="conf"
    #
    
  18. thibaultmeyer commented on Dec 22, 2016

    @thibaultmeyer
    Contributor

    @ethereal-sandeep I think you don't use our plugin, cause you have an error on the file EbeanParsedConfig.java who has been removed since the version 16.12.

    Are you sure addSbtPlugin("com.payintech" % "sbt-play-ebean" % "16.12") is in your project\plugins.sbt file ? Have you clean your project (rm targetdirectory) ?

  19. ethereal-sandeep commented on Dec 22, 2016

    @ethereal-sandeep

    my plugins.sbt

    resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
    addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.10")
    
    // Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using "PlayEbean"
    //  https://github.com/playframework/play-ebean/issues/104
    addSbtPlugin("com.payintech" % "sbt-play-ebean" % "16.11")
    
    
  20. thibaultmeyer commented on Dec 22, 2016

    @thibaultmeyer
    Contributor

    @ethereal-sandeep You don't use the right version. 16.11 don't allow configuration of document store via application.conf. You can upgrade to release/16.12.

  21. ethereal-sandeep commented on Dec 22, 2016

    @ethereal-sandeep

    @0xBAADF00D Seriously thats was the only thing ... My Bad .Let me check

  22. ethereal-sandeep commented on Dec 22, 2016

    @ethereal-sandeep

    @0xBAADF00D, @cpoissonnier Thanks man!! it finally compiled . but strangely
    [info] c.z.h.HikariDataSource - HikariPool-1 - Started.
    then again HikariPool-1 closed and HikariPool-2 started..then HikariPool-2 closed and HikariPool-3 started...this for once went till 33..

    gist of it is mentioned below...

    [info] application - Shutting down connection pool.
    [info] c.z.h.p.HikariPool - HikariPool-2 - Close initiated...
    [info] c.z.h.p.HikariPool - HikariPool-2 - Closed.
    [warn] application - Logger configuration in conf files is deprecated and has no effect. Use a logback configuration file instead.
    [info] application - Creating Pool for datasource 'default'
    [info] c.z.h.HikariDataSource - HikariPool-3 - Started.
    
    
  23. thibaultmeyer commented on Dec 22, 2016

    @thibaultmeyer
    Contributor

    Seems not related to sbt-play-ebean module. Maybe try to fix the following warning and check our datasource configuration (db.default.driver, db.default.url, db.default.username, ...)

    [warn] application - Logger configuration in conf files is deprecated and has no effect. Use a logback configuration file instead.
    

    You can read more at https://www.playframework.com/documentation/2.5.x/JavaDatabase and https://www.playframework.com/documentation/2.5.x/SettingsLogger

  24. ethereal-sandeep commented on Dec 22, 2016

    @ethereal-sandeep

    @0xBAADF00D okay, thanks !!

  25. cpoissonnier commented on Feb 23, 2017

    @cpoissonnier
    Author

    Is this issue gonna be resolved in the 4.0.0 version?

  26. allnash commented on Mar 28, 2018

    @allnash

    Which release is this going to be in?

  27. mkurz commented on Oct 8, 2026

    @mkurz
    Member

    This got closed by

    which will be part of the next releases. Since this issue is about two things, here's a summary:

    1. The error docStore has type OBJECT rather than LIST: fixed

    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 any other setting there, like ebean.docstore.url, made it fail, at runtime as well as in the sbt plugin when loading the models to enhance. Now Play Ebean only uses strings and lists below ebean. as models, and ignores everything else.

    2. Configuring Ebean in application.conf: not supported

    Ebean doesn't read Play's application.conf. It reads its own settings from conf/application.yaml or conf/application.properties (ebean.properties is deprecated). So Ebean settings in application.conf have no effect, and Play Ebean now logs a warning for such ignored settings from a .conf file. Put them into conf/application.yaml instead, which only Ebean reads, e.g.:

    ebean:
      docstore:
        url: http://127.0.0.1:9200
        active: true
        generateMapping: false
        dropCreate: false
        create: false

    Alternatively, a ServerConfigStartup (like in the comment above) can set them programmatically. Make sure it's covered by an ebean. config line, e.g. by putting it into the models package, otherwise Ebean doesn't pick it up.

    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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions