You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by Anders Nilsson Plymoth <an...@telhoc.se> on 2015/03/06 00:28:51 UTC
Exception on MongoDB
Hi,
I am just starting using MetaModel, and I am trying to connect to a
MongoDB 3.0.0 DB.
UpdateableDataContext dataContext =
DataContextFactory.createMongoDbDataContext("dude.myserver.com",
27017, "mydb", "mongodb", null);
Output:
Mar 06, 2015 12:05:45 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[dude.myserver.com:27017],
mode=SINGLE, requiredClusterType=UNKNOWN,
serverSelectionTimeout='30000 ms', maxWaitQueueSize=50}
Exception in thread "main" java.lang.NoSuchMethodError:
com.mongodb.DB.authenticate(Ljava/lang/String;[C)Z
at org.apache.metamodel.DataContextFactory.createMongoDbDataContext(DataContextFactory.java:545)
at org.apache.metamodel.DataContextFactory.createMongoDbDataContext(DataContextFactory.java:578)
The issue seems to be that MetaModel uses the deprecated
DB.authenticate method that was removed in MongoDB 3.0. Looks like
DataContextFactory needs to be rewritten.
Thanks,
Anders
Re: Exception on MongoDB
Posted by Kasper Sørensen <i....@gmail.com>.
Hi Anders,
Thank you for the notice! Yes we should upgrade the dependency to make sure
we use best practices as prescribed by the MongoDB guys. For a short term
fix I suggest that you use the constructor way of instantiating the
datacontext. That should allow you to do the DB authentication yourself:
DB db = ...;
new MongoDbDataContext(db);
Best regards,
Kasper
2015-03-06 0:28 GMT+01:00 Anders Nilsson Plymoth <an...@telhoc.se>:
> Hi,
>
> I am just starting using MetaModel, and I am trying to connect to a
> MongoDB 3.0.0 DB.
>
> UpdateableDataContext dataContext =
> DataContextFactory.createMongoDbDataContext("dude.myserver.com",
> 27017, "mydb", "mongodb", null);
>
> Output:
> Mar 06, 2015 12:05:45 AM com.mongodb.diagnostics.logging.JULLogger log
> INFO: Cluster created with settings {hosts=[dude.myserver.com:27017],
> mode=SINGLE, requiredClusterType=UNKNOWN,
> serverSelectionTimeout='30000 ms', maxWaitQueueSize=50}
> Exception in thread "main" java.lang.NoSuchMethodError:
> com.mongodb.DB.authenticate(Ljava/lang/String;[C)Z
> at
> org.apache.metamodel.DataContextFactory.createMongoDbDataContext(DataContextFactory.java:545)
> at
> org.apache.metamodel.DataContextFactory.createMongoDbDataContext(DataContextFactory.java:578)
>
> The issue seems to be that MetaModel uses the deprecated
> DB.authenticate method that was removed in MongoDB 3.0. Looks like
> DataContextFactory needs to be rewritten.
>
> Thanks,
> Anders
>