2

I am trying to connect with mLab but i am getting this error:

03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:  Caused by: java.lang.VerifyError: com/mongodb/DBPort$SaslAuthenticator
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBPort.authenticate(DBPort.java:387)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBPort.checkAuth(DBPort.java:402)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBTCPConnector.doOperation(DBTCPConnector.java:209)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBCollectionImpl.sendWriteCommandMessage(DBCollectionImpl.java:508)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBCollectionImpl.writeWithCommandProtocol(DBCollectionImpl.java:458)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBCollectionImpl.insertWithCommandProtocol(DBCollectionImpl.java:418)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:188)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:167)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBCollection.insert(DBCollection.java:93)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBCollection.insert(DBCollection.java:78)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.mongodb.DBCollection.insert(DBCollection.java:120)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.example.irakl_000.maps.server_pcg.ServerRequest$StorePostAsyncTask.doInBackground(ServerRequest.java:161)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at com.example.irakl_000.maps.server_pcg.ServerRequest$StorePostAsyncTask.doInBackground(ServerRequest.java:71)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at android.os.AsyncTask$2.call(AsyncTask.java:288)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:     at java.lang.Thread.run(Thread.java:841) 

I am following the instructions from mLab but something is wrong. I Here is my code:

        final BasicDBObject[] seedData = createSeedData();
        MongoClientURI uri  = new MongoClientURI("mongodb://<user>:<<password>@ds041861.mlab.com:port/db");
        MongoClient client = new MongoClient(uri);
        DB db = client.getDB(uri.getDatabase());

        DBCollection songs = db.getCollection("texts");

        songs.insert(seedData);// HERE IS THE ERROR

I am using mongo-java-driver-2.13.0-rc0.jar driver.

Here is a picture from mLabmLab

  • Well you showed us the image so it's not exactly a secret, did you acutally use `mongodb://:<@ds041861.mlab.com:41861/posts` as the connection string in your real code? Also please tell me that you also actually replaced the `` and `` values with your actual user and password credentials as well. – Blakes Seven Mar 10 '16 at 01:26
  • xaxa hello blakes, yes i did replaced the values with the correct ones :). Do you think that the problem is that i use java driver < 3.0.x ? –  Mar 10 '16 at 11:00
  • Have you verified that you're able to successfully connect to your mLab database using the `mongo` shell with the same credentials you're using in your Java app? – pneumee Mar 10 '16 at 16:18

1 Answers1

0

As i can see in your photo mLab uses mongod 3.0.7. You should use mongo-java-driver-3.x.x. Here is a link

Iraklis Bekiaris
  • 1,163
  • 15
  • 43