启动JMeter 3.2的时候,发现JMeter的日志里报异常,异常信息为无法找到keytool,而之前的版本并没有这个问题:
java.io.IOException: Cannot run program "keytool": CreateProcess error=2, 系统找不到指定的文件。at java.lang.ProcessBuilder.start(Unknown Source) ~[?:1.8.0_92]at org.apache.jorphan.exec.SystemCommand.run(SystemCommand.java:142) ~[jorphan.jar:3.2 r1790748]at org.apache.jorphan.exec.SystemCommand.run(SystemCommand.java:125) ~[jorphan.jar:3.2 r1790748]at org.apache.jorphan.exec.KeyToolUtils.checkKeytool(KeyToolUtils.java:436) ~[jorphan.jar:3.2 r1790748]at org.apache.jorphan.exec.KeyToolUtils.(KeyToolUtils.java:94) ~[jorphan.jar:3.2 r1790748]at org.apache.jmeter.protocol.http.proxy.ProxyControl.(ProxyControl.java:248) ~[ApacheJMeter_http.jar:3.2 r1790748]at org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui.createPortPanel(ProxyControlGui.java:708) ~[ApacheJMeter_http.jar:3.2 r1790748]at org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui.init(ProxyControlGui.java:664) ~[ApacheJMeter_http.jar:3.2 r1790748]at org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui.(ProxyControlGui.java:239) ~[ApacheJMeter_http.jar:3.2 r1790748]at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_92]at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_92]at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_92]at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_92]at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_92]at org.apache.jmeter.gui.util.MenuFactory.initializeMenus(MenuFactory.java:505) ~[ApacheJMeter_core.jar:3.2 r1790748]at org.apache.jmeter.gui.util.MenuFactory.(MenuFactory.java:169) ~[ApacheJMeter_core.jar:3.2 r1790748]at org.apache.jmeter.control.gui.TestPlanGui.createPopupMenu(TestPlanGui.java:93) ~[ApacheJMeter_core.jar:3.2 r1790748]at org.apache.jmeter.gui.tree.JMeterTreeNode.createPopupMenu(JMeterTreeNode.java:156) ~[ApacheJMeter_core.jar:3.2 r1790748]at org.apache.jmeter.gui.action.EditCommand.doAction(EditCommand.java:46) ~[ApacheJMeter_core.jar:3.2 r1790748]at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:74) ~[ApacheJMeter_core.jar:3.2 r1790748]at org.apache.jmeter.gui.action.ActionRouter.lambda$actionPerformed$0(ActionRouter.java:59) ~[ApacheJMeter_core.jar:3.2 r1790748]at java.awt.event.InvocationEvent.dispatch(Unknown Source) [?:1.8.0_92]at java.awt.EventQueue.dispatchEventImpl(Unknown Source) [?:1.8.0_92]at java.awt.EventQueue.access$500(Unknown Source) [?:1.8.0_92]at java.awt.EventQueue$3.run(Unknown Source) [?:1.8.0_92]at java.awt.EventQueue$3.run(Unknown Source) [?:1.8.0_92]at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_92]at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) [?:1.8.0_92]at java.awt.EventQueue.dispatchEvent(Unknown Source) [?:1.8.0_92]at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) [?:1.8.0_92]at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) [?:1.8.0_92]at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) [?:1.8.0_92]at java.awt.EventDispatchThread.pumpEvents(Unknown Source) [?:1.8.0_92]at java.awt.EventDispatchThread.pumpEvents(Unknown Source) [?:1.8.0_92]at java.awt.EventDispatchThread.run(Unknown Source) [?:1.8.0_92]Caused by: java.io.IOException: CreateProcess error=2, 系统找不到指定的文件。at java.lang.ProcessImpl.create(Native Method) ~[?:1.8.0_92]at java.lang.ProcessImpl.(Unknown Source) ~[?:1.8.0_92]
at java.lang.ProcessImpl.start(Unknown Source) ~[?:1.8.0_92]
... 35 more
经过网上搜索,发现已经有人给JMeter报了bug,项目的人答复在这里。大意是说这个不是个问题,因为JMeter会有多种方法尝试找到keytool,最终JMeter会从JAVA_HOME变量里找到keytool,不会影响正常使用,他已经把该日志的级别从“Error”降到“Info”,将来的版本就不会有该问题了。
如果你是个洁癖,无法忍受这个异常,可以参照这个回答,把keytool所在的目录加到PATH环境变量就可以了。