MongoDB and Spring Data – simple fixes, no digging
This is here as much as a placeholder for myself as info for anyone else. This is a list of minor and medium issues I’ve had working with MongoDB that were not instantly findable in a google search.
* “ns doesn’t exist”
In this case I was using MongoDB locally with a Spring Data connector. I suppose the ‘ns’ here probably means “namespace”…not the most well thought out error. The error, should you come across it might look like this:
Caused by: com.mongodb.CommandResult$CommandFailure: command failed [mapreduce]: { “serverUsed” : “localhost/127.0.0.1:27017″ , “errmsg” : “ns doesn’t exist” , “ok” : 0.0}
at com.mongodb.CommandResult.getException(CommandResult.java:88)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:134)
at org.springframework.data.mongodb.core.MongoTemplate.handleCommandError(MongoTemplate.java:1658)
… 35 more
The actual problem is that the specified collection name doesn’t exist in the database you are configured to talk to . Verify the database and collection name to solve the problem.
* Logging with the JS in a map-reduce job
Surpassingly difficult to find the answer to this, or I just suck at searching. Searching the mongo site itself for ‘mapreduce logging’ or ‘print’ didn’t yield clear results.
It is really, really simple.
The content will flush out the mongodb log…which hopefully you have access to…
* How do I get my oid in a spring mapreduce job so I have access to the timestamp?
I couldn’t figure this one out. Add a util.date to your json constructs. I think it’s cause spring jacks with that ID.
Posted by admin | 0 comments