Question

I have in installed MongoDB on my server and wrote a very small Java program to connect to it:

Mongo mongo = new Mongo("localhost");
db = mongo.getDB("testdb"); // testdb doesn't exist, will be created

When I run the program, I get this error:

WARNING: jmx registration error: java.security.AccessControlException:
    access denied (javax.management.MBeanTrustPermission register) continuing...

What could be causing this error? I am using the MongoDB database driver 2.7.3 supplied by MongoDB. I have changed the configuration file(s) for MongoDB since installing.

Was it helpful?

Solution

Looks to me that your security policy is not permitting MongoDB from registering its JMX method. See this question: AccessControlException when trying to redeploy webapp to Tomcat using Netbeans

It recommends to edit your security.policy file to add the line:

grant { permission javax.management.MBeanTrustPermission "register"; };

Then add the following to your VM command line arguments:

-Djava.security.policy= <path to security.policy>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top