Mrityunjay
unread,Apr 30, 2012, 1:38:19 AM4/30/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-ca...@googlegroups.com
I'm calling the following to query a file from GridFS:
val gridfs = GridFS(DB, "photos")
val file = gridfs.findOne(fileName) //errors out here
However, the code above seems randomly to throw the following exception:
Apr 30, 2012 5:10:27 AM com.mongodb.DBTCPConnector$MyPort error
SEVERE: MyPort.error called
java.lang.ClassCastException: org.joda.time.DateTime cannot be cast to java.util.Date
at com.mongodb.gridfs.GridFSFile.put(GridFSFile.java:185)
at org.bson.BasicBSONCallback._put(BasicBSONCallback.java:154)
at org.bson.BasicBSONCallback.gotDate(BasicBSONCallback.java:110)
at org.bson.BSONDecoder.decodeElement(BSONDecoder.java:156)
at org.bson.BSONDecoder._decode(BSONDecoder.java:63)
at org.bson.BSONDecoder.decode(BSONDecoder.java:42)
at com.mongodb.Response.<init>(Response.java:63)
at com.mongodb.DBPort.go(DBPort.java:110)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.call(DBPort.java:65)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:201)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
at com.mongodb.DBCollection.findOne(DBCollection.java:558)
at com.mongodb.DBCollection.findOne(DBCollection.java:547)
at com.mongodb.gridfs.GridFS.findOne(GridFS.java:144)
at com.mongodb.gridfs.GridFS.findOne(GridFS.java:136)
at com.mongodb.casbah.gridfs.GridFS$$anonfun$findOne$3.apply(GridFS.scala:215)
at com.mongodb.casbah.gridfs.GridFS$$anonfun$findOne$3.apply(GridFS.scala:215)
at com.mongodb.casbah.gridfs.GridFS.sansJodaTime(GridFS.scala:183)
at com.mongodb.casbah.gridfs.GridFS.findOne(GridFS.scala:214)
at ... <code line pasted above>
It seems that Casbah is writing in JodaDateTime to GridFS file collection but on retrieval it is trying to cast it to java.util.Date. Now why this happens only randomly is still eluding me, perhaps it could be because of the sansJodaTime hack in casbah? Any help on this will be appreciated, this is holding up our whole testing.
Regards,
Mrityunjay