JMeter 5.4打开测试计划触发NullPointerException错误求助
Hey there, let's work through this NullPointerException you're hitting when loading your test plan in JMeter 5.4. Looking at the error log, the issue pops up in the LoadRecentProject.updateRecentFileMenuItems method—this usually points to a corrupted recent projects list or a small UI bug specific to this JMeter version. Here's what you can do to resolve it:
Step 1: Clear the Recent Projects List
The most common fix for this issue is resetting JMeter's recent projects history, since the error occurs when JMeter tries to add your test plan to this list:
- Navigate to your JMeter user directory:
- Windows:
C:\Users\<YourUsername>\.jmeter - macOS/Linux:
~/.jmeter
- Windows:
- Locate either
jmeter.propertiesorrecentProjects.properties(depending on your setup):- For
jmeter.properties: Open it, find the line starting withuser.recentprojects, and set its value to an empty string likeuser.recentprojects= - For
recentProjects.properties: Simply delete this file entirely
- For
- Restart JMeter and try loading your test plan again
Step 2: Verify Your Test Plan File
It's worth checking if your MySimpleTestplan.jmx file is intact:
- Open the file in a plain text editor (like Notepad++ or VS Code)
- Confirm the XML structure is complete—no missing closing tags or invalid characters
- If you spot issues, recreate the test plan from scratch and save it again, then test loading it
Step 3: Upgrade JMeter to a Newer Version
JMeter 5.4 has several known UI-related bugs that were fixed in later releases. Upgrading to a stable version like 5.5 or newer will not only resolve this NPE but also improve overall stability and Java 11 compatibility.
Step 4: Check Your Java Environment
Double-check that your Java runtime matches the version you compiled with:
- Run
java -versionin your terminal/command prompt to confirm the runtime version is 11.0.8 (same as your javac version) - If you still run into issues, try switching to Java 8—JMeter 5.4 supports both Java 8 and 11, and some users have reported fewer UI bugs with Java 8
Error Log Reference
Here's the error you shared for context:
WARN o.a.j.g.a.Load: Unexpected error. java.lang.NullPointerException java.lang.NullPointerException: null at java.util.ArrayDeque.addLast(ArrayDeque.java:304) ~[?:?] at java.util.ArrayDeque.add(ArrayDeque.java:495) ~[?:?] at org.apache.jmeter.gui.action.LoadRecentProject.updateRecentFileMenuItems(LoadRecentProject.java:125) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.util.JMeterMenuBar.setProjectFileLoaded(JMeterMenuBar.java:144) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.MainFrame.setProjectFileLoaded(MainFrame.java:330) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.GuiPackage.setTestPlanFile(GuiPackage.java:732) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.action.Load.loadProjectFile(Load.java:136) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.action.Load.loadProjectFile(Load.java:101) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.action.Load.doActionAfterCheck(Load.java:88) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.action.AbstractActionWithNoRunningTest.doAction(AbstractActionWithNoRunningTest.java:44) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:87) ~[ApacheJMeter_core.jar:5.4] at org.apache.jmeter.gui.action.ActionRouter.lambda$actionPerformed$0(ActionRouter.java:69) ~[ApacheJMeter_core.jar:5.4] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) [?:?] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) [?:?] at java.awt.EventQueue$4.run(EventQueue.java:721) [?:?] at java.awt.EventQueue$4.run(EventQueue.java:715) [?:?] at java.security.AccessController.doPrivileged(Native Method) ~[?:?] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [?:?] at java.awt.EventQueue.dispatchEvent(EventQueue.java:740) [?:?] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?] at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?] 2020-12-09 16:54:04,150 ERROR o.a.j.u.JMeterUtils: Unexpected error - see log for details
内容的提问来源于stack exchange,提问作者user3624378

