Error: BasicBSONList can only work with numeric keys, not...

1,821 views
Skip to first unread message

jp

unread,
Apr 23, 2011, 7:58:51 PM4/23/11
to mongodb-user
I am not a java guy but need to build a simple graphical interface to
my MongoDB. I have a working PHP prototype that is managing data in a
MongoDB, when I use the Java driver in a desktop app I am unable to
retrieve any objects from my collection. I get the error
"BasicBSONList can only work with numeric keys, not: [LIST]"

My Document looks like (queried from shell):

{ "_id" : 1, "TYPE" : "101", "CREATED" :
ISODate("2011-04-23T20:27:46Z"), "LIST" : [
{
"$ref" : "data",
"$id" : 48005
},
{
"$ref" : "data",
"$id" : 48006
},
{
"$ref" : "data",
"$id" : 48007
},
{
"$ref" : "data",
"$id" : 48008
},
{
"$ref" : "data",
"$id" : 48009
},
{
"$ref" : "data",
"$id" : 48010
}
] }

All that I am doing is:

DB mongoDB =
this.mongoConnection.getDB( "myDB");

DBCollection coll =
mongoDB.getCollection( "myCollection" );

DBCursor cur = coll.find( );

while( cur.hasNext() )
{
System.out.println( cur.next() );

}

The PHP driver is access my data model quite nicely but Java is not so
happy. Any guidance is greatly appreciated.

Cheers

Eliot Horowitz

unread,
Apr 24, 2011, 2:51:28 AM4/24/11
to mongod...@googlegroups.com
Can you send the full stack trace?

Also, can you do a mongodump on the collection, and then run:
bsondump --type=debug <bson file>
so we can see exactly what types are there.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

jp

unread,
Apr 24, 2011, 5:09:37 AM4/24/11
to mongodb-user
My LIST array is pretty simple, array( array( '$ref', '$id',
'others',... ), array( '$ref', '$id', 'others',... ), ... )

Here is a snapshot from the dump:

--- new object ---
size : 359
_id
type: 16 size: 9
INT_FIELD
type: 16 size: 13
DT_FIELD
type: 9 size: 19
LIST2
type: 4 size: 161
--- new object ---
size : 149
0
type: 3 size: 144
--- new object ---
size : 141
$ref
type: 2 size: 21
$id
type: 16 size: 9
INT_FIELD1
type: 16 size: 13
INT_FIELD2
type: 16 size: 15
STRING_FIELD
type: 2 size: 11
DT_FIELD1
type: 9 size: 19
DT_FIELD2
type: 9 size: 19
LIST
type: 4 size: 15
--- new object ---
size : 5
BOOL_FIELD
type: 8 size: 14
LIST
type: 4 size: 152
--- new object ---
size : 142
0
type: 3 size: 137
--- new object ---
size : 134
$ref
type: 2 size: 19
$id
type: 16 size: 9
INT_FIELD1
type: 16 size: 16
INT_FIELD2
type: 16 size: 16
INT_FIELD3
type: 16 size: 15
INTE_FIELD4
type: 16 size: 16
DT_FIELD1
type: 9 size: 19
DT_FIELD2
type: 9 size: 19


The Java trace is as follows:


Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/
Contents/Classes/jsfd.jar
Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/
Contents/Classes/laf.jar
Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/
Contents/Classes/sunrsasign.jar
Apr 24, 2011 2:02:28 AM com.mongodb.DBTCPConnector$MyPort error
SEVERE: MyPort.error called
java.lang.IllegalArgumentException: BasicBSONList can only work with
numeric keys, not: [LIST]
at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:
161)
at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:
152)
at org.bson.types.BasicBSONList.put(BasicBSONList.java:66)
at
com.mongodb.DefaultDBCallback.objectDone(DefaultDBCallback.java:55)
at org.bson.BSONDecoder.decodeElement(BSONDecoder.java:192)
at org.bson.BSONDecoder.decodeElement(BSONDecoder.java:181)
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.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at
mongeTest.mongeTestView.jButton1ActionPerformed(mongeTestView.java:
374)
at mongeTest.mongeTestView.access$800(mongeTestView.java:31)
at mongeTest.mongeTestView
$4.actionPerformed(mongeTestView.java:189)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:
2028)
at javax.swing.AbstractButton
$Handler.actionPerformed(AbstractButton.java:2351)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:
387)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:
236)
at java.awt.Component.processMouseEvent(Component.java:6374)
at javax.swing.JComponent.processMouseEvent(JComponent.java:
3267)
at java.awt.Component.processEvent(Component.java:6139)
at java.awt.Container.processEvent(Container.java:2085)
at java.awt.Component.dispatchEventImpl(Component.java:4736)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Component.dispatchEvent(Component.java:4566)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:
4212)
at java.awt.Container.dispatchEventImpl(Container.java:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4566)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:680)
at java.awt.EventQueue.access$000(EventQueue.java:86)
at java.awt.EventQueue$1.run(EventQueue.java:639)
at java.awt.EventQueue$1.run(EventQueue.java:637)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext
$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext
$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:653)
at java.awt.EventQueue$2.run(EventQueue.java:651)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext
$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:650)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:
296)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:
211)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:
201)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:
122)
Exception in thread "AWT-EventQueue-0"
java.lang.IllegalArgumentException: BasicBSONList can only work with
numeric keys, not: [LIST]
at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:
161)
at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:
152)
at org.bson.types.BasicBSONList.put(BasicBSONList.java:66)
at
com.mongodb.DefaultDBCallback.objectDone(DefaultDBCallback.java:55)
at org.bson.BSONDecoder.decodeElement(BSONDecoder.java:192)
at org.bson.BSONDecoder.decodeElement(BSONDecoder.java:181)
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.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at
mongeTest.mongeTestView.jButton1ActionPerformed(mongeTestView.java:
374)
at mongeTest.mongeTestView.access$800(mongeTestView.java:31)
at mongeTest.mongeTestView
$4.actionPerformed(mongeTestView.java:189)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:
2028)
at javax.swing.AbstractButton
$Handler.actionPerformed(AbstractButton.java:2351)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:
387)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:
236)
at java.awt.Component.processMouseEvent(Component.java:6374)
at javax.swing.JComponent.processMouseEvent(JComponent.java:
3267)
at java.awt.Component.processEvent(Component.java:6139)
at java.awt.Container.processEvent(Container.java:2085)
at java.awt.Component.dispatchEventImpl(Component.java:4736)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Component.dispatchEvent(Component.java:4566)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:
4212)
at java.awt.Container.dispatchEventImpl(Container.java:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4566)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:680)
at java.awt.EventQueue.access$000(EventQueue.java:86)
at java.awt.EventQueue$1.run(EventQueue.java:639)
at java.awt.EventQueue$1.run(EventQueue.java:637)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext
$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext
$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:653)
at java.awt.EventQueue$2.run(EventQueue.java:651)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext
$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:650)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:
296)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:
211)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:
201)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:
122)


Cheers

Eliot Horowitz

unread,
Apr 26, 2011, 2:49:33 AM4/26/11
to mongod...@googlegroups.com
Is it possible to send the mongodump?
You can upload to http://jira.mongodb.org/ in the community private
section and only 10gen engineers will see it.
Reply all
Reply to author
Forward
0 new messages