[JAVA-2026] Use of MongoCredential throws unhandled exceptions on Android Created: 04/Nov/15  Updated: 11/Sep/19  Resolved: 04/Nov/15

Status: Closed
Project: Java Driver
Component/s: Authentication
Affects Version/s: 2.13.3, 3.1.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Greg Ennis Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: Bug, android
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Android


Issue Links:
Duplicate
duplicates JAVA-1958 SCRAM-SHA1 authentication is not avai... Closed

 Description   

I am maintaining an open source project which is an android front-end client for Mongo DB (https://github.com/grennis/MongoExplorer/). So, hardcoding credentials is not an issue here. The user types in their credentials and database connection information.

I have been using deprecated authentication mechanism MongoDatabase.authenticate(...) and it does work in most scenarios, however, it seems to no longer work (with MongoLab at least). So, I'm trying to use MongoCredential to authenticate.

However, it does not seem to work on Android.

With driver version 3.1.x I get various exceptions,
Could not find method java.lang.management.ManagementFactory.getRuntimeMXBean, referenced from method org.bson.types.ObjectId.createProcessIdentifier
VFY: unable to resolve static method 24444: Ljava/lang/management/ManagementFactory;.getRuntimeMXBean ()Ljava/lang/management/RuntimeMXBean;
And then followed by unhandled exception - java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory

With driver version 2.13.x I get exception similiar exceptions ultimately resulting in:
java.lang.VerifyError: com/mongodb/DBPort$PlainAuthenticator



 Comments   
Comment by Greg Ennis [ 04/Nov/15 ]

Sorry, I somehow didn't find that issue when I searched. Thanks

Comment by Jeffrey Yemin [ 04/Nov/15 ]

Marking as a duplicate of JAVA-1958. As I commented on that ticket, we don't consider this a bug per se as the Java driver is designed to run in a complete Java SE environment, and Android does not provide that. But still, it's something that we'll consider addressing.

Comment by Greg Ennis [ 04/Nov/15 ]

I'm trying to connect to mongo lab, it reports: mongod version: 3.0.7.

That stack overflow link does appear to be the same issue (missing Sasl classes) but the suggested solution is to use an unofficial fork from a couple months ago, it is now 93 commits behind your master and I'm not sure how it could be maintained going forward.

Comment by Jeffrey Yemin [ 04/Nov/15 ]

Is it possible you're running into the issue described here?

Comment by Jeffrey Yemin [ 04/Nov/15 ]

What version of MongoDB is the application connecting to?

Generated at Thu Feb 08 08:56:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.