Gatling 3.7.4 execution issue - ClassNotFoundException

Hi Stephane Landelle / Team
Continuing from – Upgrade Scala 2.12 · Issue #3179 · gatling/gatling · GitHub

I upgraded my Gatling and Maven to the latest version below are the snippet.

1.8 1.8 UTF-8 3.7.4 4.1.1 3.2.0 4.5.6

But when triggering the mvn command from IDE, its failing to find the Classes

mvn command – ./mvnw clean gatling:test -Dgatling.simulationClass=com.sampleproject.ProjectStoreSimulation

[ERROR] i.g.a.Gatling$ - Run crashed
java.lang.ClassNotFoundException: com.sampleproject.ProjectStoreSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)


Wrapped by: java.lang.IllegalArgumentException: User defined Simulation class com.sampleproject.ProjectStoreSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:87)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:91)



Caused by: java.lang.IllegalArgumentException: User defined Simulation class com.sampleproject.ProjectStoreSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:87)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:91)
at scala.Option.orElse(Option.scala:477)

Caused by: java.lang.ClassNotFoundException: com.sampleproject.ProjectStoreSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:4.1.1:test (default-cli) on project upgrade-store-test: Gatling failed. Process exited with an error: 255 (Exit value: 255) → [Help 1]

But when I run the Engine directly the script executes perfectly it only fails with MVN command.

–Alex Michael Raj J

Hi,

As requested in this group’s terms, please:

  • Provide a Short, Self Contained, Correct (Compilable), Example (see http://sscce.org/)

After upgrading my Gatling from 3.0.0 To 3.7.4, the script is failing to execute from mvn commandLine with the below error. Below are the error message I see as part of mvn execution.
Need help in understanding the reason for the issue.

ERROR] i.g.a.Gatling$ - Run crashed
java.lang.ClassNotFoundException: com.sampleproject.ProjectStoreSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)


Wrapped by: java.lang.IllegalArgumentException: User defined Simulation class com.sampleproject.ProjectStoreSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:87)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:91)



Caused by: java.lang.IllegalArgumentException: User defined Simulation class com.sampleproject.ProjectStoreSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:87)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:91)
at scala.Option.orElse(Option.scala:477)

Caused by: java.lang.ClassNotFoundException: com.sampleproject.ProjectStoreSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:4.1.1:test (default-cli) on project upgrade-store-test: Gatling failed. Process exited with an error: 255 (Exit value: 255) → [Help 1]

–Alex

Please provide a sample project!

Hi Stephane,
Attached the sample project.
Execution Procedure to replicate the issue:
→ After importing the project re-build the project
→ run the command ./mvnw clean gatling:test -Dgatling.simulationClass=computerDatabase.BasicSimulation on mac Intellij terminal
should be able to replicate the below error
[INFO] — gatling-maven-plugin:4.1.1:test (default-cli) @ gatling-maven-plugin-demo-scala —
16:16:27.631 [ERROR] i.g.a.Gatling$ - Run crashed
java.lang.NoClassDefFoundError: computerDatabase/BasicSimulation (wrong name: computerdatabase/BasicSimulation)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:76)
at scala.util.Try$.a

Thankyou,
–Alex

There’s no attachment.
The best way is to publish your project on GitHub.

Regards,

Hi Stephane,
Unable to attach the project in Google-groups. So I have provided access to slandelle@gatling.io for the below link.
https://drive.google.com/file/d/19ZR-6A8D1r1oExMXfDBSTVmxzL7jbeKR/view?usp=sharing

–Alex

You have a typo:

-Dgatling.simulationClass=computerDatabase.BasicSimulation

It’s computerdatabase in minor case

Hi Stephane,
My bad… I have uploaded the new version and uploaded new project.
https://drive.google.com/file/d/1pQQwy6JAAAShmXzsamol30YY_3Q4sQhO/view?usp=sharing

[INFO] — gatling-maven-plugin:4.1.1:test (default-cli) @ gatling-maven-plugin-demo-scala —
17:43:49.034 [ERROR] i.g.a.Gatling$ - Run crashed
java.lang.ClassNotFoundException: computerdatabase.BasicSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:76)
at scala.util.Try$.apply(Try.scala:210)

–Alex

You haven’t properly copied the maven configuration: https://github.com/gatling/gatling-maven-plugin-demo/blob/main/pom.xml#L29-L67

Thanks a ton Stephane, this fixed my issue.
great, alacritous response!

–Alex