Gatling 3.7.4 execution issue - ClassNotFoundException

1,436 views
Skip to first unread message

Alex Michael

unread,
Feb 15, 2022, 2:54:03 AM2/15/22
to Gatling User Group
Hi Stephane Landelle / Team

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

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- <scala.version>2.12.7</scala.version> -->
<encoding>UTF-8</encoding>
<gatling.version>3.7.4</gatling.version>
<gatling-plugin.version>4.1.1</gatling-plugin.version>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<scala-maven-plugin.version>4.5.6</scala-maven-plugin.version>
</properties>


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


Stéphane LANDELLE

unread,
Feb 15, 2022, 3:04:16 AM2/15/22
to gat...@googlegroups.com
Hi,

As requested in this group's terms, please:
  • Provide a Short, Self Contained, Correct (Compilable), Example (see http://sscce.org/)
--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/32aa17bd-bde6-48ff-a478-24fb5d525d7fn%40googlegroups.com.

Alex Michael

unread,
Feb 15, 2022, 4:16:45 AM2/15/22
to Gatling User Group
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

Stéphane LANDELLE

unread,
Feb 15, 2022, 4:17:30 AM2/15/22
to gat...@googlegroups.com
Please provide a sample project!

--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 

Alex Michael

unread,
Feb 15, 2022, 7:37:54 AM2/15/22
to Gatling User Group
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 

Stéphane LANDELLE

unread,
Feb 15, 2022, 8:08:23 AM2/15/22
to gat...@googlegroups.com
There's no attachment.
The best way is to publish your project on GitHub.

Regards,

--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 

Alex Michael

unread,
Feb 15, 2022, 8:20:59 AM2/15/22
to Gatling User Group
Hi Stephane,
Unable to attach the project in Google-groups. So I have provided access to slan...@gatling.io for the below link.

--Alex

On Tuesday, February 15, 2022 at 12:04:16 PM UTC+4 Stéphane Landelle wrote:

Stéphane LANDELLE

unread,
Feb 15, 2022, 8:23:54 AM2/15/22
to gat...@googlegroups.com
You have a typo:

-Dgatling.simulationClass=computerDatabase.BasicSimulation

It's computerdatabase in minor case

--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 

Alex Michael

unread,
Feb 15, 2022, 8:49:46 AM2/15/22
to Gatling User Group
Hi Stephane,
My bad.. I have uploaded the new version and uploaded new project.

[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

Stéphane LANDELLE

unread,
Feb 15, 2022, 9:24:01 AM2/15/22
to gat...@googlegroups.com
You haven't properly copied the maven configuration: https://github.com/gatling/gatling-maven-plugin-demo/blob/main/pom.xml#L29-L67

--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 

Alex Michael

unread,
Feb 15, 2022, 10:20:52 AM2/15/22
to Gatling User Group
Thanks a ton Stephane, this fixed my issue.
great, alacritous response! 

--Alex

Reply all
Reply to author
Forward
0 new messages