javax.management.remote.JMXConnectorFactory Java Examples
The following examples show how to use
javax.management.remote.JMXConnectorFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestManager.java From hottub with GNU General Public License v2.0 | 7 votes |
private static void connect(String pid, String address) throws Exception { if (address == null) { throw new RuntimeException("Local connector address for " + pid + " is null"); } System.out.println("Connect to process " + pid + " via: " + address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector c = JMXConnectorFactory.connect(url); MBeanServerConnection server = c.getMBeanServerConnection(); System.out.println("Connected."); RuntimeMXBean rt = newPlatformMXBeanProxy(server, RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); System.out.println(rt.getName()); // close the connection c.close(); }
Example #2
Source File: ListenerScaleTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); Sender sender = new Sender(); mbs.registerMBean(sender, testObjectName); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); JMXConnector cc = JMXConnectorFactory.connect(addr); try { test(mbs, cs, cc); } finally { cc.close(); cs.stop(); } }
Example #3
Source File: TestManager.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static void connect(String pid, String address) throws Exception { if (address == null) { throw new RuntimeException("Local connector address for " + pid + " is null"); } System.out.println("Connect to process " + pid + " via: " + address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector c = JMXConnectorFactory.connect(url); MBeanServerConnection server = c.getMBeanServerConnection(); System.out.println("Connected."); RuntimeMXBean rt = newPlatformMXBeanProxy(server, RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); System.out.println(rt.getName()); // close the connection c.close(); }
Example #4
Source File: StartManagementAgent.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void tryConnect(int port, boolean shouldSucceed) throws Exception { String jmxUrlStr = String.format( "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port); JMXServiceURL url = new JMXServiceURL(jmxUrlStr); HashMap<String, ?> env = new HashMap<>(); boolean succeeded; try { JMXConnector c = JMXConnectorFactory.connect(url, env); c.getMBeanServerConnection(); succeeded = true; } catch(Exception ex) { succeeded = false; } if (succeeded && !shouldSucceed) { throw new Exception("Could connect to agent, but should not have been possible"); } if (!succeeded && shouldSucceed) { throw new Exception("Could not connect to agent"); } }
Example #5
Source File: StartManagementAgent.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void tryConnect(int port, boolean shouldSucceed) throws Exception { String jmxUrlStr = String.format( "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port); JMXServiceURL url = new JMXServiceURL(jmxUrlStr); HashMap<String, ?> env = new HashMap<>(); boolean succeeded; try { JMXConnector c = JMXConnectorFactory.connect(url, env); c.getMBeanServerConnection(); succeeded = true; } catch(Exception ex) { succeeded = false; } if (succeeded && !shouldSucceed) { throw new Exception("Could connect to agent, but should not have been possible"); } if (!succeeded && shouldSucceed) { throw new Exception("Could not connect to agent"); } }
Example #6
Source File: RemoteConnectionGetter.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public MBeanServerConnection getMBeanServerConnection(String user, String password) throws Exception { HashMap<String,String[]> env = new HashMap<String,String[]>(); if (user != null) { String[] credentials = new String[] { user, password }; env.put("jmx.remote.credentials", credentials); } JMXConnector jmxc = JMXConnectorFactory.connect(url, env); MBeanServerConnection jmxConn = jmxc.getMBeanServerConnection(); Map<MBeanServerConnection,JMXConnector> conns = connections.get(); if (conns == null) { conns = new HashMap<MBeanServerConnection,JMXConnector>(); connections.set(conns); } conns.put(jmxConn, jmxc); return jmxConn; }
Example #7
Source File: TestManager.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void connect(String pid, String address) throws Exception { if (address == null) { throw new RuntimeException("Local connector address for " + pid + " is null"); } System.out.println("Connect to process " + pid + " via: " + address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector c = JMXConnectorFactory.connect(url); MBeanServerConnection server = c.getMBeanServerConnection(); System.out.println("Connected."); RuntimeMXBean rt = newPlatformMXBeanProxy(server, RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); System.out.println(rt.getName()); // close the connection c.close(); }
Example #8
Source File: JMXExecutor.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Instantiates a new JMXExecutor targeting the VM indicated by the given host/port combination or a full JMX * Service URL * * @param target a host/port combination on the format "host:port" or a full JMX Service URL of the target VM */ public JMXExecutor(String target) { String urlStr; if (target.matches("^\\w[\\w\\-]*(\\.[\\w\\-]+)*:\\d+$")) { /* Matches "hostname:port" */ urlStr = String.format("service:jmx:rmi:///jndi/rmi://%s/jmxrmi", target); } else if (target.startsWith("service:")) { urlStr = target; } else { throw new IllegalArgumentException("Could not recognize target string: " + target); } try { JMXServiceURL url = new JMXServiceURL(urlStr); JMXConnector c = JMXConnectorFactory.connect(url, new HashMap<>()); mbs = c.getMBeanServerConnection(); } catch (IOException e) { throw new CommandExecutorException("Could not initiate connection to target: " + target, e); } }
Example #9
Source File: ListenerScaleTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); Sender sender = new Sender(); mbs.registerMBean(sender, testObjectName); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); JMXConnector cc = JMXConnectorFactory.connect(addr); try { test(mbs, cs, cc); } finally { cc.close(); cs.stop(); } }
Example #10
Source File: TestManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void connect(String pid, String address) throws Exception { if (address == null) { throw new RuntimeException("Local connector address for " + pid + " is null"); } System.out.println("Connect to process " + pid + " via: " + address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector c = JMXConnectorFactory.connect(url); MBeanServerConnection server = c.getMBeanServerConnection(); System.out.println("Connected."); RuntimeMXBean rt = newPlatformMXBeanProxy(server, RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); System.out.println(rt.getName()); // close the connection c.close(); }
Example #11
Source File: CARBON15928JMXDisablingTest.java From product-ei with Apache License 2.0 | 6 votes |
private MBeanInfo testMBeanForDatasource() throws Exception { Map<String, String[]> env = new HashMap<>(); String[] credentials = { "admin", "admin" }; env.put(JMXConnector.CREDENTIALS, credentials); try { String url = "service:jmx:rmi://localhost:12311/jndi/rmi://localhost:11199/jmxrmi"; JMXServiceURL jmxUrl = new JMXServiceURL(url); JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl, env); MBeanServerConnection mBeanServer = jmxConnector.getMBeanServerConnection(); ObjectName mbeanObject = new ObjectName(dataSourceName + ",-1234:type=DataSource"); MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(mbeanObject); return mBeanInfo; } catch (MalformedURLException | MalformedObjectNameException | IntrospectionException | ReflectionException e) { throw new AxisFault("Error while connecting to MBean Server " + e.getMessage(), e); } }
Example #12
Source File: TestManager.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void connect(String pid, String address) throws Exception { if (address == null) { throw new RuntimeException("Local connector address for " + pid + " is null"); } System.out.println("Connect to process " + pid + " via: " + address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector c = JMXConnectorFactory.connect(url); MBeanServerConnection server = c.getMBeanServerConnection(); System.out.println("Connected."); RuntimeMXBean rt = newPlatformMXBeanProxy(server, RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); System.out.println(rt.getName()); // close the connection c.close(); }
Example #13
Source File: StartManagementAgent.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void tryConnect(int port, boolean shouldSucceed) throws Exception { String jmxUrlStr = String.format( "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port); JMXServiceURL url = new JMXServiceURL(jmxUrlStr); HashMap<String, ?> env = new HashMap<>(); boolean succeeded; try { JMXConnector c = JMXConnectorFactory.connect(url, env); c.getMBeanServerConnection(); succeeded = true; } catch(Exception ex) { succeeded = false; } if (succeeded && !shouldSucceed) { throw new Exception("Could connect to agent, but should not have been possible"); } if (!succeeded && shouldSucceed) { throw new Exception("Could not connect to agent"); } }
Example #14
Source File: TestManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void connect(String pid, String address) throws Exception { if (address == null) { throw new RuntimeException("Local connector address for " + pid + " is null"); } System.out.println("Connect to process " + pid + " via: " + address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector c = JMXConnectorFactory.connect(url); MBeanServerConnection server = c.getMBeanServerConnection(); System.out.println("Connected."); RuntimeMXBean rt = newPlatformMXBeanProxy(server, RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); System.out.println(rt.getName()); // close the connection c.close(); }
Example #15
Source File: ProviderTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static void dotest(JMXServiceURL url, MBeanServer mbs) throws Exception { JMXConnectorServer server = null; JMXConnector client = null; server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); server.start(); JMXServiceURL outputAddr = server.getAddress(); System.out.println("Server started ["+ outputAddr+ "]"); client = JMXConnectorFactory.newJMXConnector(outputAddr, null); client.connect(); System.out.println("Client connected"); MBeanServerConnection connection = client.getMBeanServerConnection(); System.out.println(connection.getDefaultDomain()); }
Example #16
Source File: ProviderTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void dotest(JMXServiceURL url, MBeanServer mbs) throws Exception { JMXConnectorServer server = null; JMXConnector client = null; server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); server.start(); JMXServiceURL outputAddr = server.getAddress(); System.out.println("Server started ["+ outputAddr+ "]"); client = JMXConnectorFactory.newJMXConnector(outputAddr, null); client.connect(); System.out.println("Client connected"); MBeanServerConnection connection = client.getMBeanServerConnection(); System.out.println(connection.getDefaultDomain()); }
Example #17
Source File: CARBON15928JMXDisablingTest.java From micro-integrator with Apache License 2.0 | 6 votes |
private MBeanInfo testMBeanForDatasource() throws Exception { Map<String, String[]> env = new HashMap<>(); String[] credentials = { "admin", "admin" }; env.put(JMXConnector.CREDENTIALS, credentials); try { String url = "service:jmx:rmi://localhost:12311/jndi/rmi://localhost:11199/jmxrmi"; JMXServiceURL jmxUrl = new JMXServiceURL(url); JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl, env); MBeanServerConnection mBeanServer = jmxConnector.getMBeanServerConnection(); ObjectName mbeanObject = new ObjectName(dataSourceName + ",-1234:type=DataSource"); MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(mbeanObject); return mBeanInfo; } catch (MalformedURLException | MalformedObjectNameException | IntrospectionException | ReflectionException e) { throw new AxisFault("Error while connecting to MBean Server " + e.getMessage(), e); } }
Example #18
Source File: RMIConnectorLogAttributesTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private JMXConnector connectToServer(JMXConnectorServer server) throws IOException, MalformedObjectNameException, NullPointerException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, ReflectionException, MBeanException { JMXServiceURL url = server.getAddress(); Map<String, Object> env = new HashMap<String, Object>(); JMXConnector connector = JMXConnectorFactory.connect(url, env); System.out.println("DEBUG: Client connected to RMI at: " + url); return connector; }
Example #19
Source File: OldMBeanServerTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public MBeanServerConnection call() { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); try { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer( url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); connector = JMXConnectorFactory.connect(addr); return connector.getMBeanServerConnection(); } catch (IOException e) { throw new RuntimeException(e); } }
Example #20
Source File: JCozServiceImpl.java From JCoz with GNU General Public License v3.0 | 5 votes |
@Override public int attachToProcess(int localProcessId) throws RemoteException { logger.info("Attaching to process {}", localProcessId); try { for (VirtualMachineDescriptor desc : VirtualMachine.list()) { if (Integer.parseInt(desc.id()) == localProcessId) { VirtualMachine vm = VirtualMachine.attach(desc); vm.startLocalManagementAgent(); Properties props = vm.getAgentProperties(); String connectorAddress = props .getProperty(CONNECTOR_ADDRESS_PROPERTY_KEY); JMXServiceURL url = new JMXServiceURL(connectorAddress); JMXConnector connector = JMXConnectorFactory.connect(url); MBeanServerConnection mbeanConn = connector .getMBeanServerConnection(); attachedVMs.put(localProcessId, JMX.newMXBeanProxy(mbeanConn, JCozProfiler.getMBeanName(), JCozProfilerMBean.class)); return JCozProfilingErrorCodes.NORMAL_RETURN; } } } catch (IOException | NumberFormatException | AttachNotSupportedException e) { StringWriter stringWriter = new StringWriter(); e.printStackTrace(new PrintWriter(stringWriter)); logger.error("Got an exception during attachToProcess, stacktrace: {}", stringWriter); throw new RemoteException("", e); } return JCozProfilingErrorCodes.INVALID_JAVA_PROCESS; }
Example #21
Source File: JVMTest.java From bistoury with GNU General Public License v3.0 | 5 votes |
public static void getVmInfo() throws Exception { VirtualMachine vm = VirtualMachine.attach(String.valueOf(10248)); // 获得连接地址 Properties properties = vm.getAgentProperties(); String address = (String) properties.get("com.sun.management.jmxremote.localConnectorAddress"); System.out.println(address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector connector = JMXConnectorFactory.connect(url); RuntimeMXBean rmxb = ManagementFactory.newPlatformMXBeanProxy(connector.getMBeanServerConnection(), "java.lang:type=Runtime", RuntimeMXBean.class); MemoryMXBean memoryMXBean = ManagementFactory.newPlatformMXBeanProxy(connector.getMBeanServerConnection(), ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class); OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.newPlatformMXBeanProxy(connector.getMBeanServerConnection(), ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class); System.out.println(operatingSystemMXBean.getSystemCpuLoad()); MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); Map<String, Object> result = new HashMap<>(); //堆提交内存 result.put("heapCommitedMemory", memoryUsage.getCommitted() / KB); //当前堆内存 result.put("heapUsedMemory", memoryUsage.getUsed() / KB); //最大堆大小 result.put("heapMaxMemory", memoryUsage.getMax() / KB); memoryUsage = memoryMXBean.getNonHeapMemoryUsage(); //非堆提交内存 result.put("nonHeapCommitedMemory", memoryUsage.getCommitted() / KB); //当前非堆内存 result.put("nonHeapUsedMemory", memoryUsage.getUsed() / KB); //最大非堆大小 result.put("nonHeapMaxMemory", memoryUsage.getMax() / KB); System.out.println(result); vm.detach(); }
Example #22
Source File: JMXRemoteManagementEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote+http://localhost:9990"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat(count).isGreaterThan(1); jmxConnector.close(); }
Example #23
Source File: OldMBeanServerTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public MBeanServerConnection call() { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); try { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer( url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); connector = JMXConnectorFactory.connect(addr); return connector.getMBeanServerConnection(); } catch (IOException e) { throw new RuntimeException(e); } }
Example #24
Source File: JMXRemoteManagementAutoEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote+http://localhost:9990"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat(count).isGreaterThan(1); jmxConnector.close(); }
Example #25
Source File: RMIDownloadTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void testWithException(boolean send) throws Exception { ClassLoader zoobyCL = new ZoobyClassLoader(); Class<?> zoobyClass = Class.forName("Zooby", false, zoobyCL); Object zooby = zoobyClass.newInstance(); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, pmbs); cs.start(); JMXServiceURL addr = cs.getAddress(); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); Object rzooby; if (send) { System.out.println("Sending object..."); mbsc.setAttribute(getSetName, new Attribute("It", zooby)); rzooby = getSetInstance.getIt(); } else { System.out.println("Receiving object..."); getSetInstance.setIt(zooby); rzooby = mbsc.getAttribute(getSetName, "It"); } if (!rzooby.getClass().getName().equals("Zooby")) { throw new Exception("FAILED: remote object is not a Zooby"); } if (rzooby.getClass().getClassLoader() == zooby.getClass().getClassLoader()) { throw new Exception("FAILED: same class loader: " + zooby.getClass().getClassLoader()); } cc.close(); cs.stop(); }
Example #26
Source File: RemoteOfflineApplicationImpl.java From ipst with Mozilla Public License 2.0 | 5 votes |
private JMXContext(JMXServiceURL url, Map<String, String> env, NotificationListener listener) throws IOException, MalformedObjectNameException, InstanceNotFoundException { this.listener = listener; connector = JMXConnectorFactory.connect(url, env); mbsc = connector.getMBeanServerConnection(); beanName = new ObjectName(LocalOfflineApplicationMBean.BEAN_NAME); application = MBeanServerInvocationHandler.newProxyInstance(mbsc, beanName, LocalOfflineApplicationMBean.class, false); mbsc.addNotificationListener(beanName, listener, null, null); }
Example #27
Source File: IIOPURLTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { JMXServiceURL inputAddr = new JMXServiceURL("service:jmx:iiop://"); JMXConnectorServer s; try { s = JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null, null); } catch (java.net.MalformedURLException x) { try { Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie"); throw new RuntimeException("MalformedURLException thrown but iiop appears to be supported"); } catch (ClassNotFoundException expected) { } System.out.println("IIOP protocol not supported, test skipped"); return; } MBeanServer mbs = MBeanServerFactory.createMBeanServer(); mbs.registerMBean(s, new ObjectName("a:b=c")); s.start(); JMXServiceURL outputAddr = s.getAddress(); if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) { throw new RuntimeException("URL path should start with \"/ior/IOR:\": " + outputAddr); } System.out.println("IIOP URL path looks OK: " + outputAddr); JMXConnector c = JMXConnectorFactory.connect(outputAddr); System.out.println("Successfully got default domain: " + c.getMBeanServerConnection().getDefaultDomain()); c.close(); s.stop(); }
Example #28
Source File: OldMBeanServerTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public MBeanServerConnection call() { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); try { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer( url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); connector = JMXConnectorFactory.connect(addr); return connector.getMBeanServerConnection(); } catch (IOException e) { throw new RuntimeException(e); } }
Example #29
Source File: OldMBeanServerTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public MBeanServerConnection call() { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); try { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer( url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); connector = JMXConnectorFactory.connect(addr); return connector.getMBeanServerConnection(); } catch (IOException e) { throw new RuntimeException(e); } }
Example #30
Source File: OldMBeanServerTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public MBeanServerConnection call() { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); try { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer( url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); connector = JMXConnectorFactory.connect(addr); return connector.getMBeanServerConnection(); } catch (IOException e) { throw new RuntimeException(e); } }