java.lang.ClassCastException: scala.collection.immutable.$colon$colon cannot be cast to scala.collection.mutable.ArrayBuffer

JIRA | Bryan J Swift | 6 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    I was performing an aggregation on a collection with approximately 4000 records in it. The record structure is: { "_id" : ObjectId("4ddc7c0498c5e77564395bb5"), "bookmark_id" : 361409, "user_id" : 94, "favorite" : false, "archive" : true, "favorite_date" : ISODate("2011-05-25T04:33:48Z"), "update_date" : ISODate("2011-05-25T04:33:48Z"), "article_id" : "j5gk326a", "article_title" : "Marcotte //", "article_url" : "http://www.scottboms.com/2011/05/marcotte/", "article_excerpt" : "The best part Ethan Marcottes new book, Responsive Web Design (available from the fine people at A Book Apart on June 7th) is that its brimming with his thoughtful ideas and unique approach.&hellip;" } The `.group` call was set up as follows: val connection = MongoConnection() val db = connection("dbname") val collection = db("collectionname") val key = MongoDBObject("article_id" -> 1, "article_title" -> 1, "article_url" -> 1, "article_excerpt" -> 1) val cond = MongoDBObject() val initial = MongoDBObject("count" -> 0, "favorite_count" -> 0) val reduce = """function(o,p) { if (o.favorite) { p.favorite_count++; } p.count++; }""" val finalizefcn = """function(out) { out.score = out.favorite_count + out.count; }""" collection.group(key, cond, initial, reduce, finalizefcn) These steps caused the following output in the REPL: java.lang.ClassCastException: scala.collection.immutable.$colon$colon cannot be cast to scala.collection.mutable.ArrayBuffer at com.mongodb.casbah.MongoCollectionBase$class.group(MongoCollection.scala:527) at com.mongodb.casbah.MongoCollection.group(MongoCollection.scala:920) at .<init>(<console>:17) at .<clinit>(<console>) at RequestResult$.<init>(<console>:9) at RequestResult$.<clinit>(<console>) at RequestResult$scala_repl_result(<console>) 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 scala.tools.nsc.Interpreter$Request$$anonfun$load... I am able to get around this by doing the score calculation as part of reduce but this seems like a significant issue.

    JIRA | 6 years ago | Bryan J Swift
    java.lang.ClassCastException: scala.collection.immutable.$colon$colon cannot be cast to scala.collection.mutable.ArrayBuffer
  2. 0

    I was performing an aggregation on a collection with approximately 4000 records in it. The record structure is: { "_id" : ObjectId("4ddc7c0498c5e77564395bb5"), "bookmark_id" : 361409, "user_id" : 94, "favorite" : false, "archive" : true, "favorite_date" : ISODate("2011-05-25T04:33:48Z"), "update_date" : ISODate("2011-05-25T04:33:48Z"), "article_id" : "j5gk326a", "article_title" : "Marcotte //", "article_url" : "http://www.scottboms.com/2011/05/marcotte/", "article_excerpt" : "The best part Ethan Marcottes new book, Responsive Web Design (available from the fine people at A Book Apart on June 7th) is that its brimming with his thoughtful ideas and unique approach.&hellip;" } The `.group` call was set up as follows: val connection = MongoConnection() val db = connection("dbname") val collection = db("collectionname") val key = MongoDBObject("article_id" -> 1, "article_title" -> 1, "article_url" -> 1, "article_excerpt" -> 1) val cond = MongoDBObject() val initial = MongoDBObject("count" -> 0, "favorite_count" -> 0) val reduce = """function(o,p) { if (o.favorite) { p.favorite_count++; } p.count++; }""" val finalizefcn = """function(out) { out.score = out.favorite_count + out.count; }""" collection.group(key, cond, initial, reduce, finalizefcn) These steps caused the following output in the REPL: java.lang.ClassCastException: scala.collection.immutable.$colon$colon cannot be cast to scala.collection.mutable.ArrayBuffer at com.mongodb.casbah.MongoCollectionBase$class.group(MongoCollection.scala:527) at com.mongodb.casbah.MongoCollection.group(MongoCollection.scala:920) at .<init>(<console>:17) at .<clinit>(<console>) at RequestResult$.<init>(<console>:9) at RequestResult$.<clinit>(<console>) at RequestResult$scala_repl_result(<console>) 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 scala.tools.nsc.Interpreter$Request$$anonfun$load... I am able to get around this by doing the score calculation as part of reduce but this seems like a significant issue.

    JIRA | 6 years ago | Bryan J Swift
    java.lang.ClassCastException: scala.collection.immutable.$colon$colon cannot be cast to scala.collection.mutable.ArrayBuffer

    Root Cause Analysis

    1. java.lang.ClassCastException

      scala.collection.immutable.$colon$colon cannot be cast to scala.collection.mutable.ArrayBuffer

      at com.mongodb.casbah.MongoCollectionBase$class.group()
    2. casbah-core
      MongoCollection.group
      1. com.mongodb.casbah.MongoCollectionBase$class.group(MongoCollection.scala:527)
      2. com.mongodb.casbah.MongoCollection.group(MongoCollection.scala:920)
      2 frames