Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I end up with java.lang.IllegalArgumentException for Casbah / Java MongoDB Driver?

I'm seeing a strange issue using the casbah / java driver.

I keep running into the following exception when the driver tries to create a response from mongo:

   Oct 16, 2012 10:45:07 AM com.mongodb.DBTCPConnector$MyPort error   SEVERE: MyPort.error called   java.lang.IllegalArgumentException: response too long: 1634610484     at com.mongodb.Response.(Response.java:40)     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.DBCursor._check(DBCursor.java:354)     at com.mongodb.DBCursor._hasNext(DBCursor.java:484)     at com.mongodb.DBCursor.hasNext(DBCursor.java:509)     at com.mongodb.casbah.MongoCursorBase$class.hasNext(MongoCursor.scala:73)     at com.mongodb.casbah.MongoCursor.hasNext(MongoCursor.scala:497)     at scala.collection.Iterator$class.foreach(Iterator.scala:660)     at com.mongodb.casbah.MongoCursor.foreach(MongoCursor.scala:497)         ... 

This seems to be happening at random, even in cases where mongo shouldn't be returning any results from the query. The size reported is inconsistent and normally way larger than it should or could be.

I'm guessing this is probably some form of corruption with the response. I've had a difficult time making heads or tails of this problem using Wireshark, but I consistently find that the request/response chain leading up to the query whose response throws this error has "TCP Window Full" response coming from MongoDB:

enter image description here

The versions I'm using:

  Casbah: 2.1.5.0  Mongo Java Driver: 2.5.3  MongoDB: 2.2 

I'd greatly appreciate it if anyone could give any advice on what I may potentially be doing wrong or any pointers on how to further debug this issue

UPDATE: After looking at the release notes for Casbah 2.1.5.0, it appears that the version of the java driver being used is 2.5.3, not 2.7.3

like image 315
Bryan Avatar asked Oct 16 '12 15:10

Bryan


People also ask

What is MongoDB Java driver?

A standalone BSON library, with a new Codec infrastructure that you can use to build high-performance encoders and decoders without requiring an intermediate Map instance. MongoDB Driver.

Is Java required for MongoDB?

Installation. Before you start using MongoDB in your Java programs, you need to make sure that you have MongoDB CLIENT and Java set up on the machine. You can check Java tutorial for Java installation on your machine.

What is MongoDB Java?

MongoDB is an open-source cross-platform document database developed using C++. Some features of MongoDB are: High and effective performance. Easily scalable.


2 Answers

The version of the Java driver you're using is not compatible with MongoDB 2.2. You should be using at least 2.9.3, if not 2.10 or higher. There's no guarantee a driver upgrade will fix your problem, but it should be a first step.

https://support.mongolab.com/entries/22631012-which-drivers-support-mongodb-2-2

like image 57
jared Avatar answered Oct 15 '22 01:10

jared


How big is your JSON object? See if that big object is supported by the version of mongodb.

like image 42
Prateek Avatar answered Oct 15 '22 01:10

Prateek