0

Recently i've been having an issue on application startup, using MongoDB 2.10.1, with my JavaEE application running on Jboss 4.2.3GA.

 AM com.mongodb.DBPortPool$Holder get
 WARNING: JMX registration error: com.mongodb.util.management.JMException:
 javax.management.NotCompliantMBeanException: Class does not expose a management
 Class does not expose a management interface: java.lang.Object
 Consider setting com.mongodb.MongoOptions.alwaysUseMBeans property to true.
 Continuing...

My application handles database queries using Stateless Session Beans, from what i've seen, there is a MongoOptions setting to alwaysUseMBeans for Java6 or higher users, while running on Jboss. However, while attempting to set alwaysUseMBeans to true via the Java Driver, there is no such setter available.

Has anyone else had a similar problem, or is there a solution i'm missing?

1 Answers1

0

He tells you the answer in the Exception itself... i just ran into the same failure like you. Java don't like it if you're using the Datatype "Object" somewhere in your data -> there is always a more specific Datatype in Java which you should use instead of Object.

But i know the problem, i'm running in the same shizzle after changing a Map like this

Map<String, String> map = new HashMap<String, String>();

into this

Map<String, Object> map = new HashMap<String, Object>();

And i have to change it to object because some values are Strings, and some others are Integers, and the Integers must be Integers (not Strings) -> just because it is semantically wrong with Strings..

So it was the easiest way in my Example to simply Change the Map into a String-Object-Construct. The better way would be to create a

BasicDBObject().append("myField", aValueOfTheCorrectDatatype);

and append the values you like in the correct Datatype.

Or, you set this option in MongoDB Driver like he tells you in the Exception:

MongoClientOptions.Builder builder = new MongoClientOptions.Builder().alwaysUseMBeans(true);
mongo = new MongoClient(configuration.getEpgMongoDbHost(), builder.build());

But yeah... super funny... i set the option and i still get this stupid Exception, oh i love this! that's always so great when documented stuff is just lying! :D Ok well i will gonna change my Map into a BasicDBObject someday, currently.. i just ignore this Exception, everything works well ^^

jebbie
  • 1,418
  • 3
  • 17
  • 27