org.bson.BsonInvalidOperationException: readString can only be called when CurrentBSONType is STRING, not when CurrentBSONType is ARRAY.

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Monocleとかいうのがありまして - SSSSLIDE
    via by Unknown author,
  • Monocleとかいうのがありまして
    via by Unknown author,
  • Can't read BsonBinary
    via Stack Overflow by nairod
    ,
  • What I tried to do is to run a code from [the documentation|http://mongodb.github.io/mongo-java-driver/3.0/driver/reference/crud/#codecregistry] to use {{BasicDBObject}} in the new CRUD API. My test document contained a BSON symbol and I got an exception where I didn't expect to have one. {code:text} scala> import com.mongodb._ import com.mongodb._ scala> val db = new MongoClient("localhost").getDatabase("test") июл 31, 2015 7:59:31 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} db: com.mongodb.client.MongoDatabase = com.mongodb.MongoDatabaseImpl@2ff5be19 scala> июл 31, 2015 7:59:31 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Opened connection [connectionId{localValue:1, serverValue:6}] to localhost:27017 июл 31, 2015 7:59:31 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 4]}, minWireVersion=0, maxWireVersion=3, electionId=null, maxDocumentSize=16777216, roundTripTimeNanos=560000} scala> scala> db.getCollection("test").find.first июл 31, 2015 7:59:52 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Opened connection [connectionId{localValue:2, serverValue:7}] to localhost:27017 res0: org.bson.Document = Document{{_id=55bb50acb5b97f6d98b6186c, i32=1, s=str, sym=symbol}} scala> db.getCollection("test", classOf[BasicDBObject]).find.first org.bson.BsonInvalidOperationException: readString can only be called when CurrentBSONType is STRING, not when CurrentBSONType is SYMBOL. at org.bson.AbstractBsonReader.verifyBSONType(AbstractBsonReader.java:655) at org.bson.AbstractBsonReader.checkPreconditions(AbstractBsonReader.java:687) at org.bson.AbstractBsonReader.readString(AbstractBsonReader.java:428) at org.bson.codecs.StringCodec.decode(StringCodec.java:35) at org.bson.codecs.StringCodec.decode(StringCodec.java:27) at com.mongodb.DBObjectCodec.readValue(DBObjectCodec.java:306) at com.mongodb.DBObjectCodec.readDocument(DBObjectCodec.java:345) at com.mongodb.DBObjectCodec.decode(DBObjectCodec.java:136) at com.mongodb.DBObjectCodec.decode(DBObjectCodec.java:61) at com.mongodb.connection.ReplyMessage.<init>(ReplyMessage.java:57) at com.mongodb.connection.QueryProtocol.receiveMessage(QueryProtocol.java:290) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:229) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:38) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) at com.mongodb.connection.DefaultServerConnection.query(DefaultServerConnection.java:166) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:397) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:394) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168) at com.mongodb.operation.FindOperation.execute(FindOperation.java:394) at com.mongodb.operation.FindOperation.execute(FindOperation.java:57) at com.mongodb.Mongo.execute(Mongo.java:738) at com.mongodb.Mongo$2.execute(Mongo.java:725) at com.mongodb.FindIterableImpl$FindOperationIterable.first(FindIterableImpl.java:197) at com.mongodb.FindIterableImpl.first(FindIterableImpl.java:140) ... 43 elided {code}
    via by Alexander Azarov,
  • What I tried to do is to run a code from [the documentation|http://mongodb.github.io/mongo-java-driver/3.0/driver/reference/crud/#codecregistry] to use {{BasicDBObject}} in the new CRUD API. My test document contained a BSON symbol and I got an exception where I didn't expect to have one. {code:text} scala> import com.mongodb._ import com.mongodb._ scala> val db = new MongoClient("localhost").getDatabase("test") июл 31, 2015 7:59:31 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} db: com.mongodb.client.MongoDatabase = com.mongodb.MongoDatabaseImpl@2ff5be19 scala> июл 31, 2015 7:59:31 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Opened connection [connectionId{localValue:1, serverValue:6}] to localhost:27017 июл 31, 2015 7:59:31 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 4]}, minWireVersion=0, maxWireVersion=3, electionId=null, maxDocumentSize=16777216, roundTripTimeNanos=560000} scala> scala> db.getCollection("test").find.first июл 31, 2015 7:59:52 PM com.mongodb.diagnostics.logging.JULLogger log INFO: Opened connection [connectionId{localValue:2, serverValue:7}] to localhost:27017 res0: org.bson.Document = Document{{_id=55bb50acb5b97f6d98b6186c, i32=1, s=str, sym=symbol}} scala> db.getCollection("test", classOf[BasicDBObject]).find.first org.bson.BsonInvalidOperationException: readString can only be called when CurrentBSONType is STRING, not when CurrentBSONType is SYMBOL. at org.bson.AbstractBsonReader.verifyBSONType(AbstractBsonReader.java:655) at org.bson.AbstractBsonReader.checkPreconditions(AbstractBsonReader.java:687) at org.bson.AbstractBsonReader.readString(AbstractBsonReader.java:428) at org.bson.codecs.StringCodec.decode(StringCodec.java:35) at org.bson.codecs.StringCodec.decode(StringCodec.java:27) at com.mongodb.DBObjectCodec.readValue(DBObjectCodec.java:306) at com.mongodb.DBObjectCodec.readDocument(DBObjectCodec.java:345) at com.mongodb.DBObjectCodec.decode(DBObjectCodec.java:136) at com.mongodb.DBObjectCodec.decode(DBObjectCodec.java:61) at com.mongodb.connection.ReplyMessage.<init>(ReplyMessage.java:57) at com.mongodb.connection.QueryProtocol.receiveMessage(QueryProtocol.java:290) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:229) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:38) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) at com.mongodb.connection.DefaultServerConnection.query(DefaultServerConnection.java:166) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:397) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:394) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168) at com.mongodb.operation.FindOperation.execute(FindOperation.java:394) at com.mongodb.operation.FindOperation.execute(FindOperation.java:57) at com.mongodb.Mongo.execute(Mongo.java:738) at com.mongodb.Mongo$2.execute(Mongo.java:725) at com.mongodb.FindIterableImpl$FindOperationIterable.first(FindIterableImpl.java:197) at com.mongodb.FindIterableImpl.first(FindIterableImpl.java:140) ... 43 elided {code}
    via by Alexander Azarov,
  • Error with mongodb gorm plugin!
    via GitHub by redraushan
    ,
    • org.bson.BsonInvalidOperationException: readString can only be called when CurrentBSONType is STRING, not when CurrentBSONType is ARRAY. at org.bson.AbstractBsonReader.verifyBSONType(AbstractBsonReader.java:655) at org.bson.AbstractBsonReader.checkPreconditions(AbstractBsonReader.java:687) at org.bson.AbstractBsonReader.readString(AbstractBsonReader.java:428)

    Users with the same issue

    Dunmer
    Dunmer39 times, last one,
    Unknown visitor1 times, last one,