Tag Archives: java

MongoDB: can only have 1 index plugin / bad index key pattern

MongoDB: can only have 1 index plugin / bad index key pattern

While working with MongoDB and the MongoDB Java driver I got the following exception when attempting to iterate over a result set.

com.mongodb.MongoException: can only have 1 index plugin / bad index key pattern
at com.mongodb.MongoException.parse(MongoException.java:82)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:312)
at com.mongodb.DBCursor._check(DBCursor.java:369)
at com.mongodb.DBCursor._hasNext(DBCursor.java:498)
at com.mongodb.DBCursor.hasNext(DBCursor.java:523)

This exception drove me nuts. I checked the index definition in Java, which looked fine, compared it to the index result in Mongo shell (db.collectionName.getIndexes()), which looked fine too, made several desperate attempts to drop and recreate the index, re-index the collection, etc.

Then I cut down the DB query and recognized that removing my sort() call made a difference. Eventually it turned out that the sort order was specified as a String instead of an Integer, see below:

BasicDBObject query = ...
// BasicDBObject sort = new BasicDBObject("column1", "1").append("column2", "-1");
BasicDBObject sort = new BasicDBObject("column1", 1).append("column2", -1);

Android Game Development (Day 6)

It took some time until I finally could get back to my little Android game and I must admit that this wasn’t really a “day” I worked on it. Instead, it were multiple, scattered and short sessions where I worked on the collision testing and response code, some effects and UI stuff. It’s simply too hot currently… so bear with me that there’s no cool video this time.

ProjectA - Now with collision testing and explosions

ProjectA - Now with collision testing and explosions

Keep reading below if you’re interested in the recent progress. Comments are welcome! In case you missed it, also don’t forget to read the earlier reports on my steps in Android game development: Steps 1-3, Step 4, Step 5.

Android Game Development

I’m building rather boring enterprise applications at work and I love creating more appealing things in my spare time, so I do a bit of game development whenever I can. The main problem for a programmer is to get some graphics, but fortunately I have some nice renderings from my old Project E tutorial and the even older Project D game by sechsta sinn on my harddisk that I could put into use (all done by my friend and favorite artist Martin Ernst, btw.).

This is what I managed to do in three after work sessions so far, if you’re interested in the details, continue reading after the video.

Android Game Development – Steps 1-3 from Matthias Gall on Vimeo.

Android Developer Challenge

Google has announced the second Android Developer Challenge and I’m seriously considering taking part. They have ten different categories with three attractive prizes each and one overall category with three even more attractive prizes. Given the facts that there were only 1788 submissions last year, that I have already gathered some experience in mobile device development and that I do work with several Google APIs for my freelancing job I consider my chances not too bad. Idea, anyone? 😉