Running JMeter from apachejmeter.jar - Giving an error in the Jmeter Script execution, Works when run with jmeter.bat file

Viewed 22

I have a simple JMeter script , where I am using parallel controller to send few GET requests. When I am running the script ,by loading the JMeter using jmeter.bat file. The Jmeter Test works without any error. When I am running JMeter from ApacheJmetr.jar file from the bin , I am getting the below error So I wanted to know what exactly is the difference as it is working from jmeter.bat file and not from apachejmeter.jar file.

java.lang.reflect.InaccessibleObjectException: Unable to make field java.lang.ThreadLocal$ThreadLocalMap java.lang.Thread.inheritableThreadLocals accessible: module java.base does not "opens java.lang" to unnamed module @222114ba
    at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[?:?]
    at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[?:?]
    at java.lang.reflect.Field.checkCanSetAccessible(Field.java:180) ~[?:?]```


1 Answers

jmeter.bat startup script is a wrapper which generates some parameters for the Java Virtual Machine, in particular your error is due to missing parameterse which are set in line 112 (for JMeter 5.5)

So you either need to:

  1. Downgrade your Java to Java 8

  2. Or to add the same JVM arguments as jmeter.bat startup script does, to wit:

    java --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED -jar ApacheJMeter.jar
    
Related