I\'m developing an Android app that use the java mongodb driver 3.0.3 to connect to every instance of mongodb.
The connector code to a generic istance is:
It looks to me like the ManagementFactory is a red herring, as the driver catches that exception and falls back to using a random number instead.
The real problem appears to be that the driver needs to authenticate with SCRAM-SHA-1, the implementation of which imports the following classes:
import javax.crypto.Mac;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import javax.security.sasl.SaslClient;
import javax.security.sasl.SaslException;
I suspect that these are not available in the Android platform, which is not a complete implementation of the Java Runtime Environment.
One thing you could try would be to run against MongoDB 2.6, against which the driver's authentication implementation only relies on java.security.MessageDigest.
Another thing to think about is putting a REST service between the mobile app and MongoDB that is responsible for proxying all interactions with the database. The REST application can be run in an environment where the MongoDB driver will be fully functional.