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

流过昼夜 提交于 2019-12-21 07:00:11

问题


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:

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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/12917943/why-do-i-end-up-with-java-lang-illegalargumentexception-for-casbah-java-mongod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!