Mrityunjay
未讀,2012年4月30日 凌晨1:38:192012/4/30登入以回覆作者
登入以轉寄訊息
你的權限不足,無法在這個群組刪除訊息
登入以檢舉訊息
該群組的電子郵件地址為匿名,或你需要檢視成員電子郵件地址的權限才能查看原始貼文
收件者: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