运行 GUI 时出现 Jmeter NullPointerException

Jmeter NullPointerException when running the GUI

我已经使用

安装了 Jmeter

brew install Jmeter

当我运行

jmeter

从命令行我得到这个错误:

mac@macbook ~ $ jmeter
================================================================================ 
Don't use GUI mode for load testing !, only for Test creation and Test
debugging. For load testing, use CLI Mode (was NON GUI):    
 jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder] & increase Java Heap to meet your test requirements:    Modify current
env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m" in the
jmeter batch file Check :
https://jmeter.apache.org/usermanual/best-practices.html
================================================================================ 
An error occurred: null

我检查了 jmeter.log 文件,这是我得到的:


2019-12-03 09:48:06,190 ERROR o.a.j.JMeter: An error occurred: 
java.lang.NullPointerException: null  at
java.awt.Window.init(Window.java:497) ~[?:1.8.0_231]  at
java.awt.Window.<init>(Window.java:537) ~[?:1.8.0_231]    at
java.awt.Frame.<init>(Frame.java:420) ~[?:1.8.0_231]  at
java.awt.Frame.<init>(Frame.java:385) ~[?:1.8.0_231]  at
javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1763)
~[?:1.8.0_231]    at
javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1838)
~[?:1.8.0_231]    at javax.swing.JWindow.<init>(JWindow.java:187)
~[?:1.8.0_231]    at javax.swing.JWindow.<init>(JWindow.java:139)
~[?:1.8.0_231]    at
org.apache.jmeter.SplashScreen.<init>(SplashScreen.java:45)
~[ApacheJMeter_core.jar:5.2.1]    at
org.apache.jmeter.JMeter.startGui(JMeter.java:376)
~[ApacheJMeter_core.jar:5.2.1]    at
org.apache.jmeter.JMeter.start(JMeter.java:545)
[ApacheJMeter_core.jar:5.2.1]     at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.8.0_231]    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[?:1.8.0_231]    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:1.8.0_231]    at java.lang.reflect.Method.invoke(Method.java:498)
~[?:1.8.0_231]    at
org.apache.jmeter.NewDriver.main(NewDriver.java:253)
[ApacheJMeter.jar:5.2.1]

Java版本:

java version "1.8.0_231" Java(TM) SE Runtime Environment (build
1.8.0_231-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

有人能解决这个问题吗?

会不会是你用的DisplayLink? If so, most probably you're suffering from Java Apps crash on launch if connected to external DisplayLink device问题。

根据 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure 文章:

Use Up-to-Date Software

Your test might fail if your software is out of date. Make sure you’re using the most recent versions of the following:

Java - use the latest 64-bit version of Java SE JDK or Server JRE where possible

因此,如果您必须留在 Java 8 - 考虑升级到 Java SE Development Kit 8u231 (or whatever is the latest stable patch level), otherwise obtain the latest version of Java Runtime Environment or SDK

如果您无法修改 Java 版本 - 考虑删除此 DisplayLink 设备。

我遇到了与

上的 OP 相同的问题
mac os mojave 10.14.6, 
openjdk version "1.8.0_232"(Corretto-8.232.09.1 build 1.8.0_232-b09) and
jmeter 5.3. 

我的 mac 笔记本电脑连接了外接显示器。断开两个显示器。打开翻盖。重新连接两个显示器。现在,jmeter GUI 启动正常。