java.lang.IllegalArgumentException: Could not instantiate Collection type: java.util.EnumSet

Spring JIRA | Milan Skuhra | 3 years ago
  1. 0

    Using EnumSet as collection for enums caused exception when BasicDBList from database is mapped back to EnumSet. Stack trace when version org.springframework.data:spring-data-mongodb:1.3.3.RELEASE is used: {code} java.lang.IllegalArgumentException: Could not instantiate Collection type: java.util.EnumSet at org.springframework.core.CollectionFactory.createCollection(CollectionFactory.java:258) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readCollectionOrArray(MappingMongoConverter.java:778) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readValue(MappingMongoConverter.java:1048) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.access$100(MappingMongoConverter.java:77) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:999) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getValueInternal(MappingMongoConverter.java:755) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:256) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:249) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:257) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:249) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:223) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:187) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:183) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:77) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1975) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1671) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1496) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1480) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:527) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:518) ... Caused by: java.lang.InstantiationException: java.util.EnumSet at java.lang.Class.newInstance0(Class.java:342) at java.lang.Class.newInstance(Class.java:310) at org.springframework.core.CollectionFactory.createCollection(CollectionFactory.java:255) ... {code}

    Spring JIRA | 3 years ago | Milan Skuhra
    java.lang.IllegalArgumentException: Could not instantiate Collection type: java.util.EnumSet
  2. 0

    Using EnumSet as collection for enums caused exception when BasicDBList from database is mapped back to EnumSet. Stack trace when version org.springframework.data:spring-data-mongodb:1.3.3.RELEASE is used: {code} java.lang.IllegalArgumentException: Could not instantiate Collection type: java.util.EnumSet at org.springframework.core.CollectionFactory.createCollection(CollectionFactory.java:258) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readCollectionOrArray(MappingMongoConverter.java:778) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readValue(MappingMongoConverter.java:1048) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.access$100(MappingMongoConverter.java:77) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:999) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getValueInternal(MappingMongoConverter.java:755) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:256) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:249) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:257) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:249) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:223) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:187) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:183) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:77) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1975) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1671) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1496) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1480) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:527) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:518) ... Caused by: java.lang.InstantiationException: java.util.EnumSet at java.lang.Class.newInstance0(Class.java:342) at java.lang.Class.newInstance(Class.java:310) at org.springframework.core.CollectionFactory.createCollection(CollectionFactory.java:255) ... {code}

    Spring JIRA | 3 years ago | Milan Skuhra
    java.lang.IllegalArgumentException: Could not instantiate Collection type: java.util.EnumSet
  3. 0

    [SPR-7293] CollectionsToCollectionsConverter no longer handles java.util.Collections$EmptyList -> java.util.Collections$EmptyList - Spring JIRA

    spring.io | 1 year ago
    org.springframework.core.convert.ConversionFailedException: Unable to convert value "[]" from type 'java.util.Collections$EmptyList' to type 'java.util.Collections$EmptyList'; nested exception is java.lang.IllegalArgumentException: Could not instantiate Collection type: java.util.Collections$EmptyList
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    samebug tip
    I was missing a partitioning column because I did not specify the "basePath" option on read
  6. 0
    samebug tip
    Index settings can't be on the nodes via elasticsearch.yml. You need to set them at your index, or using index templates to avoid inconsistencies.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Could not instantiate Collection type: java.util.EnumSet

      at org.springframework.core.CollectionFactory.createCollection()
    2. Spring Core
      CollectionFactory.createCollection
      1. org.springframework.core.CollectionFactory.createCollection(CollectionFactory.java:258)
      1 frame
    3. Spring Data MongoDB - Core
      MappingMongoConverter$1.doWithPersistentProperty
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.readCollectionOrArray(MappingMongoConverter.java:778)
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.readValue(MappingMongoConverter.java:1048)
      3. org.springframework.data.mongodb.core.convert.MappingMongoConverter.access$100(MappingMongoConverter.java:77)
      4. org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:999)
      5. org.springframework.data.mongodb.core.convert.MappingMongoConverter.getValueInternal(MappingMongoConverter.java:755)
      6. org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:256)
      7. org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:249)
      7 frames
    4. Spring Data Core
      BasicPersistentEntity.doWithProperties
      1. org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:257)
      1 frame
    5. Spring Data MongoDB - Core
      MongoTemplate.find
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:249)
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:223)
      3. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:187)
      4. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:183)
      5. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:77)
      6. org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1975)
      7. org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1671)
      8. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1496)
      9. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1480)
      10. org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:527)
      11. org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:518)
      11 frames