1

java.lang.NoSuchMethodError: com.mongodb.DBCollection.save(Lcom/mongodb/DBObject;)V

Here is the sample code. Error is on Line 3.

1   BasicDBObject dbo=new BasicDBObject(data);
2   DBCollection coll = new Mongo().getDB("test")
3   coll.save(dbo);
4   data.put(Entity.DB_ID, dbo.get(Entity.DB_ID));

Strangely, this error is showing when running as webapp from Tomcat6 and using mongo 2.4 or 2.5.3. With 2.0.rc3, it works fine. I want to use 2.5.3 Also, when runing from eclipse, or commandline, it works with all the three versions(2.0 ,2.4, 2.5.3) And the DBCollection class is being loaded because coll.insert(), coll.find() are working. Just that it is saying NoSuchMethodError when I call save().

This is a fresh install of Ubuntu 10.4 and tomcat6 on top of it. The JDK is OpenJDK java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.7) (6b20-1.9.7-0ubuntu1~10.04.1)

user81240
  • 11
  • 4

1 Answers1

1

Sounds like you need to recompile here and make sure you targets are clean, if there were conlicting mongo jar files from different versions in the class path then a change in the moethod return (which I think there is in 2.0 --> 2.5) would cause this kind of problem.

Adam C
  • 5,132
  • 2
  • 28
  • 49