GridFSDBFile sporadic ClassCastException

93 views
Skip to first unread message

Carlos Quiroz

unread,
Mar 6, 2014, 1:37:29 PM3/6/14
to mongodb-ca...@googlegroups.com
Hi

I have a spray application that uses casbah and needs to read GridFS. My application works in general ok but there is a small percentage of cases where I get this:

app: java.lang.ClassCastException: com.mongodb.gridfs.GridFSDBFile cannot be cast to com.mongodb.casbah.gridfs.GridFSDBFileSafeJoda
app: at com.mongodb.casbah.gridfs.GridFS.findOne(GridFS.scala:215) ~[casbah-gridfs_2.10-2.6.5.jar:2.6.5]

I'm running a small benchmark that loads the same file all over and only sometimes I get this exception

Just in case I'm not using JodaTime nor calling the RegisterJodaTimeHelpers method

Cheers
Carlos

Alex FY

unread,
Aug 26, 2014, 5:08:12 AM8/26/14
to mongodb-ca...@googlegroups.com
I got the same exception only once with casbah 2.7.1 : 

 java.lang.ClassCastException: com.mongodb.gridfs.GridFSDBFile cannot be cast to com.mongodb.casbah.gridfs.GridFSDBFileSafeJoda
at com.mongodb.casbah.gridfs.GridFS.findOne(GridFS.scala:214) ~[org.mongodb.casbah-gridfs_2.11-2.7.1.jar:2.7.1]
at com.mongodb.casbah.gridfs.GridFS.findOne(GridFS.scala:221) ~[org.mongodb.casbah-gridfs_2.11-2.7.1.jar:2.7.1]
at com.fontyou.factory.services.FileService.findFileById(FileService.scala:46) ~[services.services-0.1-SNAPSHOT.jar:0.1-SNAPSHOT]
        ...

Alex FY

unread,
Aug 29, 2014, 3:59:29 AM8/29/14
to mongodb-ca...@googlegroups.com
I have this exception every day on my production server since i upgrade to casbah 2.7.1 from 2.5.0.
I don't use Casbah JodaTime features, only java.util.Date, can I disable joda features?

Alex FY

unread,
Sep 11, 2014, 5:19:21 AM9/11/14
to mongodb-ca...@googlegroups.com
Nobody have this problem ?

I upgraded to 2.7.3
waiting for a better solution i use this workaround : 

  def findFileById(id: String): Option[Blob] = {
    val doc = try {
      gridFS.findOne(whereIdIs(id))
    } catch {
      case e:java.lang.ClassCastException if(e.getMessage() == "com.mongodb.gridfs.GridFSDBFile cannot be cast to com.mongodb.casbah.gridfs.GridFSDBFileSafeJoda") => {
        log.warn(e.getMessage + " try again")
        gridFS.findOne(whereIdIs(id))
      }
    }
    doc.map(toBlob)
  }


Ross Lawley

unread,
Sep 11, 2014, 5:29:15 AM9/11/14
to mongodb-ca...@googlegroups.com
Hi Alex,

Just to confirm are you using Joda Dates in your application? Have you registered the handlers?

Ross

--
You received this message because you are subscribed to the Google Groups "mongodb-casbah-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Elmar Weber

unread,
Oct 2, 2015, 5:35:14 AM10/2/15
to mongodb-casbah-users
Hello,

we encountered this issue today, unable to reproduce in a stable manner, every few tries it occurs. The workaround with a retry is of course a solution, but I was wondering if anyone has an idea / Update on this?

We do not use JodaTime and we use casbah 2.8.2 with mongodb 3.0 and Scala 2.11.7

Thanks,
Elmar
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-users+unsub...@googlegroups.com.

Alex FY

unread,
Jan 7, 2016, 7:34:22 AM1/7/16
to mongodb-casbah-users
Hi,

I only use java.util.Date
And i don't register the handler.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-users+unsub...@googlegroups.com.

Ross Lawley

unread,
Jan 7, 2016, 8:18:37 AM1/7/16
to mongodb-ca...@googlegroups.com
Hi Alex,

Unfortunately, no one has been able to provide a test case reproducing the issue.  If you're still seeing this issue it would be good to understand what data is causing it and if you can abstract it into a test case.

Ross

To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mongodb-casbah-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-u...@googlegroups.com.

Elmar Weber

unread,
Jan 7, 2016, 10:24:08 AM1/7/16
to mongodb-casbah-users
Hi,

I would not be able to give a reproduceable test case because it happens only sporadic, we actually implemented in code for this case a handler that retries with the exact same data. 90% of the cases it works on the first try, 96% on the 2nd, 99% 3rd, some require a fourth and fifths. After the 10th we break off, but so far no one reached this level =)

Not sure what would help you to debug it further?

Thanks,
Elmar
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-users+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mongodb-casbah-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-users+unsub...@googlegroups.com.

Ross Lawley

unread,
Jan 7, 2016, 11:50:34 AM1/7/16
to mongodb-ca...@googlegroups.com
This is bizarre - what versions of Scala and Casbah are you running?

To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mongodb-casbah-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mongodb-casbah-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-casbah-u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--


{ name     : "Ross Lawley",
  title    : "Senior Software Engineer",
  location : "London, UK",
  twitter  : ["@RossC0", "@MongoDB"],
  facebook :"MongoDB"}

Elmar Weber

unread,
Jan 8, 2016, 6:24:22 AM1/8/16
to mongodb-casbah-users
On Thursday, January 7, 2016 at 5:50:34 PM UTC+1, Ross Lawley wrote:
This is bizarre -

I agree =)
 
what versions of Scala and Casbah are you running?

We are using Scala 2.11.7 and Casbah 2.8.2.
Reply all
Reply to author
Forward
0 new messages