I am opening a JMX Connection using getMBeanServerConnection() method and then closing it after use in a finally block. And, for a given JMX Connector, 2 successful calls to getMBeanServerConnection() usually returns the same MBeanServerConnection.
Some of the operations are invoked concurrently, and each of them invokes getMBeanServerConnection(). But, they get the SAME connection. And, therefore, when the first operation completes, the remaining operation fails with "Connection Closed" error.
How can I go about resolving this? Should I create multiple connector objects and invoke getMBeanServerConnection() on them to retrieve different connections? Or, do I need to make this method synchronized (and reduce efficiency)?