MongoDB BSON size exceeded even when using GridFS

I am seeing this error while saving documents in a GridFS (MongoDB version: 2.4.12)

2015-05-15 10:19:15,409 ERROR [STDERR] com.mongodb.MongoInternalException: DBObject of size 160038724 is over Max BSON size 16777216
2015-05-15 10:19:15,409 ERROR [STDERR]  at com.mongodb.OutMessage.putObject(OutMessage.java:291)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.mongodb.OutMessage.writeUpdate(OutMessage.java:175)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.mongodb.OutMessage.update(OutMessage.java:62)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:326)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.mongodb.DBCollection.update(DBCollection.java:160)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.mongodb.DBCollection.save(DBCollection.java:800)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.mongodb.DBCollection.save(DBCollection.java:768)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.mongodb.gridfs.GridFSFile.save(GridFSFile.java:54)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.test.service.state.MongoStateOps.update(MongoStateOps.java:87)
2015-05-15 10:19:15,410 ERROR [STDERR]  at com.test.service.state.impl.StateOutputMarshallerImpl$1.run(StateOutputMarshallerImpl.java:45)
2015-05-15 10:19:15,410 ERROR [STDERR]  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
2015-05-15 10:19:15,410 ERROR [STDERR]  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
2015-05-15 10:19:15,410 ERROR [STDERR]  at java.lang.Thread.run(Thread.java:662)

Here is the code:

public void update(String correlatorId, byte[] bytes) {
        Date now = new Date(System.currentTimeMillis());
        if ( gfs )  {
            GridFSDBFile state = gridFs.findOne(correlatorId);
            state.put( correlatorLastModificationDateMappingField, now );
            state.put( correlatorBytesMappingField, bytes );
            state.save();
        } 
    }

Any help is appreciated.

Cheers


Source: java

Leave a Reply