Error querying GridFS

瀏覽次數:81 次
跳到第一則未讀訊息

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

Brendan W. McAdams

未讀,
2012年4月30日 上午10:20:182012/4/30
收件者:mongodb-ca...@googlegroups.com
As noted in the documentation, GridFS is currently incompatible with
the registration of custom date objects.

Mrityunjay

未讀,
2012年4月30日 晚上10:57:432012/4/30
收件者:mongodb-ca...@googlegroups.com
But we're not using any custom date objects here. If you check the stack trace the error comes up when reading uploadDate field of files collection in GridFS which is not supplied by us, it is auto updated with a date on saving a file.


On Monday, April 30, 2012 7:50:18 PM UTC+5:30, Brendan W. McAdams wrote:
As noted in the documentation, GridFS is currently incompatible with
the registration of custom date objects.


Brendan W. McAdams

未讀,
2012年4月30日 晚上11:00:272012/4/30
收件者:mongodb-ca...@googlegroups.com
You are using the Joda DateTime serializers… those are incompatible with GridFS.
回覆所有人
回覆作者
轉寄
0 則新訊息