I hope you’re all doing well. I’m currently facing an issue while trying to run Gatling, and I could really use your expertise and guidance to resolve it. Before I dive into the details, I’d like to express my gratitude in advance for your help and support. Your time and assistance are highly valued, and I promise to maintain a polite and respectful tone throughout this discussion.
Context:
I’m using Gatling for load testing, and I’ve encountered a Java Virtual Machine (JVM) error while running my tests.
Issue Description:
Here’s the command I’m using to run Gatling:
sh ${GATLING_BIN_DIR}/gatling.sh \
-rm local \
-s TestSimulation \
-rd "Test" \
-rf ${WORKSPACE}/user-files/results \
-sf ${WORKSPACE}/user-files/simulations \
-rsf ${WORKSPACE}/user-files/resources
And here’s the error message I’m encountering:
Error: VM option 'UseG1GC' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Info:
Model Name: MacBook Air
Chip: Apple M2
java version "1.8.0_381"
Java(TM) SE Runtime Environment (build 1.8.0_381-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode)
Thank you for your support!
Ps. I tested adding the option via -ecjo "-XX:+UnlockExperimentalVMOptions" & --extra-run-jvm-options "-XX:+UnlockExperimentalVMOptions" and directly in the .sh script, but has the same error.
Which version of Gatling do you use? Latest is 3.9.5 and the script doesn’t contain the UseG1GC option (anymore).
If you do use the latest version, look into your JAVA_OPTS environment variables.
I also echoed my $JAVA_OPTS and $JAVA_HOME but they’re blank, empty. I guess the script is using the java command on the $PATH:
if [ -n "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME"/bin/java
else
JAVA=java
fi
/bin/gatling.sh
I’ve uninstalled my java of dubious origin, as I don’t really remember installing it, and installed the JDK from Adoptium and that weird error is now gone, but I’m having an error on the simulation, as I haven’t changed anything and this is just a cloned script I image it’s something with my environment again, any ideas?
08:05:56.924 [ERROR] i.g.a.Gatling$ - Run crashed
java.lang.ClassNotFoundException: TestSimulation
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:73)
at scala.util.Try$.apply(Try.scala:210)
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:73)
... 20 common frames omitted
Wrapped by: java.lang.IllegalArgumentException: User defined Simulation class TestSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:84)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:88)
at scala.Option.orElse(Option.scala:477)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:88)
at scala.Option.flatMap(Option.scala:283)
at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:87)
at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:50)
at scala.Option.getOrElse(Option.scala:201)
at io.gatling.app.Selection$Selector.selection(Selection.scala:42)
at io.gatling.app.Selection$.apply(Selection.scala:35)
at io.gatling.app.Runner.run(Runner.scala:53)
at io.gatling.app.Gatling$.start(Gatling.scala:89)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:51)
at io.gatling.app.Gatling$.main(Gatling.scala:39)
at io.gatling.app.Gatling.main(Gatling.scala)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.gatling.plugin.util.ForkMain.runMain(ForkMain.java:67)
at io.gatling.plugin.util.ForkMain.main(ForkMain.java:35)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.gatling.plugin.util.ForkMain.runMain(ForkMain.java:67)
at io.gatling.plugin.util.ForkMain.main(ForkMain.java:35)
Caused by: java.lang.IllegalArgumentException: User defined Simulation class TestSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:84)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:88)
at scala.Option.orElse(Option.scala:477)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:88)
at scala.Option.flatMap(Option.scala:283)
at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:87)
at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:50)
at scala.Option.getOrElse(Option.scala:201)
at io.gatling.app.Selection$Selector.selection(Selection.scala:42)
at io.gatling.app.Selection$.apply(Selection.scala:35)
at io.gatling.app.Runner.run(Runner.scala:53)
at io.gatling.app.Gatling$.start(Gatling.scala:89)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:51)
at io.gatling.app.Gatling$.main(Gatling.scala:39)
at io.gatling.app.Gatling.main(Gatling.scala)
... 6 more
Caused by: java.lang.ClassNotFoundException: TestSimulation
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:73)
at scala.util.Try$.apply(Try.scala:210)
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:73)
... 20 more
I make little investigation and wen you provide by -rm local -s TestSimulation name of Class that don’t exist (TestSimulation in this case) you get java.lang.ClassNotFoundException: TestSimulation
So please check if you have this Class in place.