This discussion is archived
2 Replies Latest reply: May 17, 2013 12:55 PM by 1009653 RSS

Problem acquiring MBeanServerConnection 2nd time

MichaelT Newbie
Currently Being Moderated
JMX Client Code Snippet:
m_jmxConnector = JMXConnectorFactory.newJMXConnector(m_jmxServiceUrl, env);
m_jmxConnector.connect();
m_jmxConnection = m_jmxConnector.getMBeanServerConnection();

JMX Agent Code Snippet:
String userDir = System.getProperty("user.dir");
HashMap<String,String> env = new HashMap<String,String>();
env.put("jmx.remote.x.password.file", userDir + File.separator + "jvm_diagnostics.password");
env.put("jmx.remote.x.access.file", userDir + File.separator + "jvm_diagostics.access");
env.put(RMIConnectorServer.JNDI_REBIND_ATTRIBUTE, "true");
m_jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(m_jmxServiceUrl, env, m_mbeanServer);

Problem: The JMX agent is stopped and then restarted. The JMX client detects the JMX agent process recycle and attempts to reconnect. When the JMX agent attempts to connect the 2nd time it gets an invalid MBeanServerConnection frm the JMXConnector. No exceptions are thrown until the MBeanServerConnection is used. Upon inspecting the MBeanServerConnection acquired the 2nd time I see that the 'terminated' member is 'true'. I do see this line in the doc for getMBeanServerConnection...

"For a given JMXConnector, two successful calls to this method will usually return the same MBeanServerConnection object, though this is not required."

It appears as if the 2nd pass through the JMX client code returns the same MBeanServerConnection that was acquired the first time through but that MBeanServerConnection is no longer valid.

Is it possible to force JMXConnector to not reuse the MBeanServerConnection?

Edited by: MichaelT on Apr 17, 2013 9:18 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points