Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink 2.6: Authentication issue with MongoDB 3.0.2(NoSuchMethodError: com.mongodb.DB.authenticate)
EclipseLink 2.6: Authentication issue with MongoDB 3.0.2 [message #1698645] Tue, 16 June 2015 22:23
Muhammad Naveed is currently offline Muhammad NaveedFriend
Messages: 1
Registered: June 2015
Junior Member
Included Libraries and Versions:

1) javax.persistence_2.1.0.v201304241213.jar
2) eclipselink.jar (2.6)
3) org.eclipse.persistence.nosql_2.6.0.v20150309-bf26070
4) javax.resource_1.6.0.v201204270900.jar
5) mongo-java-driver-3.0.2.jar
6) javax.ws.rs-api-2.0.1.jar

At this point of time all the libraries are greatest and latest.

I got following error when authenticated to MongoDB version 3.0
"NoSuchMethodError: com.mongodb.DB.authenticate..."

Exception in thread "main" javax.persistence.PersistenceException: java.lang.NoSuchMethodError: com.mongodb.DB.authenticate(Ljava/lang/String;[C)Z


Exception in thread "main" javax.persistence.PersistenceException: java.lang.NoSuchMethodError: com.mongodb.DB.authenticate(Ljava/lang/String;[C)Z
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:812)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:305)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:303)
at dbaccess.api.DbAccess.getEntityManager(DbAccess.java:77)
at dbaccess.api.DbAccess.<init>(DbAccess.java:48)
at eikonuseraccount.Actions.<init>(Actions.java:26)
at eikonuseraccount.DeltaSync.<init>(DeltaSync.java:23)
at eikonuseraccount.MainProgram.main(MainProgram.java:59)
Caused by: java.lang.NoSuchMethodError: com.mongodb.DB.authenticate(Ljava/lang/String;[C)Z
at org.eclipse.persistence.internal.nosql.adapters.mongo.MongoConnectionFactory.getConnection(MongoConnectionFactory.java:96)
at org.eclipse.persistence.eis.EISConnectionSpec.connectToDataSource(EISConnectionSpec.java:151)
at org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec.connectToDataSource(MongoConnectionSpec.java:160)
at org.eclipse.persistence.eis.EISLogin.connectToDatasource(EISLogin.java:73)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:346)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:434)
at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:217)
at org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:505)
at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:488)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:760)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:255)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:728)
... 9 more



    private EntityManager getEntityManager() {
        MongoJCAConnectionSpec mongoSpec = new MongoJCAConnectionSpec();
        mongoSpec.setUser("user1");
        mongoSpec.setPassword("blah".toCharArray());

        MongoConnectionSpec spec = new MongoConnectionSpec();        
        spec.setConnectionSpec(mongoSpec);
        Map<String, Object> dbProps = new HashMap<>();
        
        dbProps.put("eclipselink.target-database", "org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform");
        dbProps.put("eclipselink.nosql.connection-spec", spec);
        dbProps.put("eclipselink.nosql.property.mongo.host", AppConfig.getMongoDbServer());
        dbProps.put("eclipselink.nosql.property.mongo.port", AppConfig.getDbPort().toString());
        dbProps.put("eclipselink.nosql.property.mongo.db", "myMongodb");
        dbProps.put("eclipselink.logging.level", "CONFIG");
        dbProps.put("eclipselink.weaving", "false");

        EntityManagerFactory em = Persistence.createEntityManagerFactory("MongoPU", dbProps);
        return em.createEntityManager();
    }


The above authentication error comes when executing this line
return em.createEntityManager();

The code works good if I omit authentication.

Also i tried to use the older mongoDB driver "com.mongodb_2.6.5.1.jar" but that gave me authentication failed error. This is because the change in default authentication mechansim in mongodb 3.0
PS: mongo 2.6 uses MONGODB-CR auth protocol and 3.0 uses MONGODB-SHA-1 by default.

Any help would be appreciated for authenticating user in mongodb 3.0 with eclipselink jpa.

Thanks

Muhammad A. Naveed
Previous Topic:Using @NamedPLSQLStoredFunctionQuery with boolean IN param, 'SYS.SQLJUTL' not installed
Next Topic:Customize instantiation of EntityListener
Goto Forum:
  


Current Time: Sun Oct 13 16:48:40 GMT 2024

Powered by FUDForum. Page generated in 0.04077 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top