javaserializationjmeterjmeter-maven-pluginjava-21

How to save test logs for Jmeter test in Java 21 with Maven?


I'm trying to execute test with Jmeter dependecies as described in this guide: https://www.baeldung.com/java-jmeter-create-run-test-scripts. However with Java JDK 21 there is error:

com.thoughtworks.xstream.converters.ConversionException: No converter available
---- Debugging information ----
message             : No converter available
type                : java.util.IdentityHashMap
converter           : com.thoughtworks.xstream.converters.reflection.SerializableConverter
message[1]          : Unable to make private void java.util.IdentityHashMap.readObject(java.io.ObjectInputStream) throws java.io.IOException,java.lang.ClassNotFoundException accessible: module java.base does not "opens java.util" to unnamed module @1442d7b5
converter[1]        : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
message[2]          : Unable to make field transient java.util.Set java.util.AbstractMap.keySet accessible: module java.base does not "opens java.util" to unnamed module @1442d7b5
-------------------------------

    at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:88)

Is it because saveTree() method involves xstream serialization and it is not supported by JDK 21?

When this method and the logic saving test logs is commented, then the test executes, but test execution details can be read. How is it possible to have test execution Jmeter logs in any format with Java 21?

Thank you


Solution

  • You need to pass certain JVM arguments to your Java process, in particular the ones from line 112 of jmeter.bat startup script

    --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
    

    Also the guide you're referring violates JMeter Best Practices, in particular it suggests using XML output instead of CSV and it creates massive disk IO and is not suitable for high-throughput tests.

    And finally since JMeter 5.6 it's officially possible to create test plan programmatically or even generate code from JMeter GUI

    enter image description here

    so you might want to re-visit your approach.