java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Iterable

Spring JIRA | Paweł Mendelski | 4 years ago
  1. 0

    When I create a query on document {{_id}} with {{$in}} operator and reuse that query to do another search i get {{ClassCastException}}. Query creation: {code:java} query.addCriteria(Criteria.where("_id").in(signedPetitionIds)); {code} Reusing query (as a filterQuery argument): {code:java} private Page<PetitionHeader> findPetitionHeaders(Pageable pageable, Query filterQuery, Sort sort) { long count = mongoOp.count(filterQuery, PetitionHeader.class); filterQuery.with(pageable); filterQuery.with(sort); List<PetitionHeader> headers = mongoOp.find(filterQuery, PetitionHeader.class); return new PageImpl<PetitionHeader>(headers, pageable, count); } {code} Stacktrace: {noformat} java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Iterable at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:159) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:90) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:112) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:79) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1337) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1323) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:495) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:486) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] {noformat} Object returned by {{valueDbo.get(inKey)}} (in line 159) is of type {{Object[]}}.

    Spring JIRA | 4 years ago | Paweł Mendelski
    java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Iterable
  2. 0

    When I create a query on document {{_id}} with {{$in}} operator and reuse that query to do another search i get {{ClassCastException}}. Query creation: {code:java} query.addCriteria(Criteria.where("_id").in(signedPetitionIds)); {code} Reusing query (as a filterQuery argument): {code:java} private Page<PetitionHeader> findPetitionHeaders(Pageable pageable, Query filterQuery, Sort sort) { long count = mongoOp.count(filterQuery, PetitionHeader.class); filterQuery.with(pageable); filterQuery.with(sort); List<PetitionHeader> headers = mongoOp.find(filterQuery, PetitionHeader.class); return new PageImpl<PetitionHeader>(headers, pageable, count); } {code} Stacktrace: {noformat} java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Iterable at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:159) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:90) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:112) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:79) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1337) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1323) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:495) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:486) ~[spring-data-mongodb-1.2.1.RELEASE.jar:na] {noformat} Object returned by {{valueDbo.get(inKey)}} (in line 159) is of type {{Object[]}}.

    Spring JIRA | 4 years ago | Paweł Mendelski
    java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Iterable
  3. 0

    While upgrading from M5 to GA I started getting this error in my tests: {noformat} java.lang.ClassCastException: com.mongodb.BasicDBObject cannot be cast to com.mongodb.BasicDBList at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:324) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:294) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.convertToMongoType(MappingMongoConverter.java:850) at org.springframework.data.mongodb.core.QueryMapper.getMappedObject(QueryMapper.java:106) at org.springframework.data.mongodb.core.QueryMapper.getMappedObject(QueryMapper.java:102) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1259) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1248) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:471) at net.emota.together.service.PersonService.createOrUpdateGroupPersons(PersonService.java:372) at net.emota.together.core.itest.service.PersonServiceIT.createOrUpdateGroupPersons(PersonServiceIT.java:303) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68) {noformat} The query I am using is simple (and involves $in, maybe releated to my previous issue?): {code} { "fbUserId" : { "$in" : [ "88888" , "ABCDE" , "12345"]} } {code}

    Spring JIRA | 5 years ago | Harlan Iverson
    java.lang.ClassCastException: com.mongodb.BasicDBObject cannot be cast to com.mongodb.BasicDBList
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    While upgrading from M5 to GA I started getting this error in my tests: {noformat} java.lang.ClassCastException: com.mongodb.BasicDBObject cannot be cast to com.mongodb.BasicDBList at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:324) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:294) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.convertToMongoType(MappingMongoConverter.java:850) at org.springframework.data.mongodb.core.QueryMapper.getMappedObject(QueryMapper.java:106) at org.springframework.data.mongodb.core.QueryMapper.getMappedObject(QueryMapper.java:102) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1259) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1248) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:471) at net.emota.together.service.PersonService.createOrUpdateGroupPersons(PersonService.java:372) at net.emota.together.core.itest.service.PersonServiceIT.createOrUpdateGroupPersons(PersonServiceIT.java:303) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68) {noformat} The query I am using is simple (and involves $in, maybe releated to my previous issue?): {code} { "fbUserId" : { "$in" : [ "88888" , "ABCDE" , "12345"]} } {code}

    Spring JIRA | 5 years ago | Harlan Iverson
    java.lang.ClassCastException: com.mongodb.BasicDBObject cannot be cast to com.mongodb.BasicDBList
  6. 0

    EntityPlayerMP cannot be cast to java.lang.Iterable in GenericArguments.player

    GitHub | 9 months ago | viveleroi
    java.lang.ClassCastException: net.minecraft.entity.player.EntityPlayerMP cannot be cast to java.lang.Iterable

    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.ClassCastException

      [Ljava.lang.Object; cannot be cast to java.lang.Iterable

      at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue()
    2. Spring Data MongoDB - Core
      MongoTemplate.find
      1. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:159)[spring-data-mongodb-1.2.1.RELEASE.jar:na]
      2. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:90)[spring-data-mongodb-1.2.1.RELEASE.jar:na]
      3. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:112)[spring-data-mongodb-1.2.1.RELEASE.jar:na]
      4. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:79)[spring-data-mongodb-1.2.1.RELEASE.jar:na]
      5. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1337)[spring-data-mongodb-1.2.1.RELEASE.jar:na]
      6. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1323)[spring-data-mongodb-1.2.1.RELEASE.jar:na]
      7. org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:495)[spring-data-mongodb-1.2.1.RELEASE.jar:na]
      8. org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:486)[spring-data-mongodb-1.2.1.RELEASE.jar:na]
      8 frames