Tag Archives: jmx 

Error in JMeter import JMX file cannotresolveclassexception: kg.apc.jmeter.perfmon.perfmoncollector solution

When using jmeter5.1.1 to import external scripts today, you will be prompted with an error message: cause: cannotresolveclassexception: kg.apc.jmeter.perfmon.perfmoncollector detail: com.thoughtworks.xstream.converters.conversionexception: — debugging information —- cause exception: com.thoughtworks.xstream.converters.conve

 

Cause: the jar package is missing, but we don’t know which one is missing, so we can go to the official website to download the JMeter plug-in manager, let the manager automatically detect the necessary jar package when importing JMX files, and then click Install to download automatically.

1. JMeter plug-in manager download address: https://jmeter-plugins.org/install/Install/

 

2. Put the plug-ins in this folder

 

3. Restart JMeter, drag the script into, and you will be prompted to install

 

4. JMeter restarts and completes the script import

jmxÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ

JavaScript implementation: how to write beautiful conditional expression>>>

Project requirements: through JMX monitoring zookeeper, the effect is similar to jconsole, but presented in the form of web. In the process of using, when JMX in the web container connects to mbeanserver to obtain the connection, it always fails. The prompt message is: Java. Lang. classnotfoundexception: org. Apache. Naming. Java. Javaurlcontextfactory. But it can be accessed normally when calling through the main method

The code is as follows:

            String jmxURL = "service:jmx:rmi:///jndi/rmi://" + ip + ":" + jmxport + "/jmxrmi";
			// jmxurl
			JMXServiceURL serviceURL = new JMXServiceURL(jmxURL);

			Map<String, String[]> map = new HashMap<String, String[]>();
			String[] credentials = new String[] { userName, password };
			map.put("jmx.remote.credentials", credentials);
			connector = JMXConnectorFactory.connect(serviceURL, map);
			MBeanServerConnection mbsc = connector.getMBeanServerConnection();

After searching for information from the Internet, from an article( http://canofy.iteye.com/blog/758748 )The method to get mbeanserverconnection is modified, and then it can run normally. The modified code is as follows:

            Registry registry = LocateRegistry.getRegistry(host, Integer.parseInt(port));
			RMIServer stub = null;
			if (stub == null) {
				stub = (RMIServer) registry.lookup("jmxrmi");
			}
			Map<String, String[]> map = new HashMap<String, String[]>();
			String[] credentials = new String[] { username, password };
			map.put("jmx.remote.credentials", credentials);
			connector = new RMIConnector(stub, null);
			connector.connect(map);
			mbsc = connector.getMBeanServerConnection();

There are two ways to get mbeanserverconnection. In general, both ways are OK. For some special applications, API means that the second method is best used