I'm trying to use Mongo Database from within my Agent (using Jade agent framework). Trying to write something to database from Agent somehow did not succeed with NoClassDefFoundError
.
The code is very simple as followings:
public class SomeAgent extends Agent {
protected void setup(){
addBehaviour(new OneShotBehaviour() {
@Override
public void action() {
MongoClient mc;
try {
mc = new MongoClient();
DB db = mc.getDB("foo");
DBCollection collection = db.getCollection("bar");
DBObject dbobject = (DBObject) JSON.parse("{something:1}");
collection.insert(dbobject);
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
});
}
}
The error is java.lang.NoClassDefFoundError: com/mongodb/MongoClient
, but I already included mongo java driver in eclipse build path. This is really strange. Could any of you know the potential cause for this? Any hint is much appreciated.