Getting the error -> java.lang.ClassNotFoundException: nextgen.SetUpApplyFlowAndLottery

Hi,

I am trying to upgrade from Gatling 3.5 to 3.7. I think I already did it

My steps to do the upgrade:

1- Changed some values in the pom.xml
2- Ran the command → mvn clean install

I did not get any error and my pom.xml now looks like:

I am running the following command to run a Gatling script that was working in version 3.5:

mvn -Dorganization=lottery_test5 -Denvironment=performance -Dyear=2021 gatling:test -Dgatling.simulationClass=nextgen.SetUpApplyFlowAndLottery

but now I got the following error

OpenJDK 64-Bit Server VM warning: Option UseBiasedLocking was deprecated in version 15.0 and will likely be removed in a future release.
16:18:09.376 [main][ERROR][Gatling.scala:90] i.g.a.Gatling$ - Run crashed
java.lang.ClassNotFoundException: nextgen.SetUpApplyFlowAndLottery
        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:520)
        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:76)
        at scala.util.Try$.apply(Try.scala:210)
        at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:76)
        ... 21 common frames omitted
Wrapped by: java.lang.IllegalArgumentException: User defined Simulation class nextgen.SetUpApplyFlowAndLottery 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)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:91)
        at scala.Option.flatMap(Option.scala:283)
        at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:90)
        at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
        at scala.Option.getOrElse(Option.scala:201)
        at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
        at io.gatling.app.Selection$.apply(Selection.scala:36)
        at io.gatling.app.Runner.run0(Runner.scala:61)
        at io.gatling.app.Runner.run(Runner.scala:49)
        at io.gatling.app.Gatling$.start(Gatling.scala:87)
        at io.gatling.app.Gatling$.fromArgs(Gatling.scala:49)
        at io.gatling.app.Gatling$.main(Gatling.scala:38)
        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.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:53)
        at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:34)
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.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:53)
        at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:34)
Caused by: java.lang.IllegalArgumentException: User defined Simulation class nextgen.SetUpApplyFlowAndLottery 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)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:91)
        at scala.Option.flatMap(Option.scala:283)
        at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:90)
        at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
        at scala.Option.getOrElse(Option.scala:201)
        at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
        at io.gatling.app.Selection$.apply(Selection.scala:36)
        at io.gatling.app.Runner.run0(Runner.scala:61)
        at io.gatling.app.Runner.run(Runner.scala:49)
        at io.gatling.app.Gatling$.start(Gatling.scala:87)
        at io.gatling.app.Gatling$.fromArgs(Gatling.scala:49)
        at io.gatling.app.Gatling$.main(Gatling.scala:38)
        at io.gatling.app.Gatling.main(Gatling.scala)
        ... 6 more
Caused by: java.lang.ClassNotFoundException: nextgen.SetUpApplyFlowAndLottery
        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:520)
        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:76)
        at scala.util.Try$.apply(Try.scala:210)
        at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:76)
        ... 21 more

For privacy policies in my company i cannot share the fully script but this is the beginning

package nextgen

import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import scala.util.Random

class SetUpApplyFlowAndLottery extends Simulation {

	/*
	 * The value is passed through the CLI in the parameter -Denvironment=[env]
	 * e.g: -Denvironment=performance
	 * This is enviroment specific, and should exactly match. The base URL is built with this.
	 */
	val env = System.getProperty("environment")

Why am i getting this error ? did i do something wrong in the upgrade ? do i have to add something else in the pom.xml file ? do i have to check something else ?

I do think it’s about the change in maven plugin.
In setup section, the note explains that you have to add scala-maven-plugin since version 4 of the Gatling maven plugin.
Did you set it up?

Moreover, the scala-faker_2.12 is not compabible with Scala 2.13 that required since Gatling 3.5.

You have to upgrade to:

<dependency>
  <groupId>com.github.pjfanning</groupId>
  <artifactId>scala-faker_2.13</artifactId>
  <version>0.5.3</version>
</dependency>

@slandelle @sbrevet i really appreciate your help but unfortunately I did those 2 changes and still getting the same error

now my pom.xml file looks like:

when I execute mvn clean install in the directory where i have my pom.xml file

[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< nextgen:nextgen-gatling >-----------------------
[INFO] Building nextgen-gatling 3.7.6
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ nextgen-gatling ---
[INFO] Deleting /Users/anthonyplaymithsanchez/Documents/repos_schoolmint/nextgen-gatling/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ nextgen-gatling ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/anthonyplaymithsanchez/Documents/repos_schoolmint/nextgen-gatling/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ nextgen-gatling ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ nextgen-gatling ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ nextgen-gatling ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ nextgen-gatling ---
[INFO] 
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ nextgen-gatling ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/anthonyplaymithsanchez/Documents/repos_schoolmint/nextgen-gatling/target/nextgen-gatling-3.7.6.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ nextgen-gatling ---
[INFO] Installing /Users/anthonyplaymithsanchez/Documents/repos_schoolmint/nextgen-gatling/target/nextgen-gatling-3.7.6.jar to /Users/anthonyplaymithsanchez/.m2/repository/nextgen/nextgen-gatling/3.7.6/nextgen-gatling-3.7.6.jar
[INFO] Installing /Users/anthonyplaymithsanchez/Documents/repos_schoolmint/nextgen-gatling/pom.xml to /Users/anthonyplaymithsanchez/.m2/repository/nextgen/nextgen-gatling/3.7.6/nextgen-gatling-3.7.6.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.448 s
[INFO] Finished at: 2022-03-30T09:48:53-06:00
[INFO] ------------------------------------------------------------------------

when i try to execute the gatling script that was working in version 3.5

(base) anthonyplaymithsanchez@Anthony-Playmith nextgen-gatling % mvn -Dorganization=spark -Denvironment=dev -Dyear=2021 gatling:test -Dgatling.simulationClass=nextgen.SetUpApplyFlowAndLottery
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< nextgen:nextgen-gatling >-----------------------
[INFO] Building nextgen-gatling 3.7.6
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> gatling-maven-plugin:4.1.3:test (default-cli) > test-compile @ nextgen-gatling >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ nextgen-gatling ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/anthonyplaymithsanchez/Documents/repos_schoolmint/nextgen-gatling/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ nextgen-gatling ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ nextgen-gatling ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ nextgen-gatling ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< gatling-maven-plugin:4.1.3:test (default-cli) < test-compile @ nextgen-gatling <<<
[INFO] 
[INFO] 
[INFO] --- gatling-maven-plugin:4.1.3:test (default-cli) @ nextgen-gatling ---
OpenJDK 64-Bit Server VM warning: Option UseBiasedLocking was deprecated in version 15.0 and will likely be removed in a future release.
09:45:05.511 [main][ERROR][Gatling.scala:90] i.g.a.Gatling$ - Run crashed
java.lang.ClassNotFoundException: nextgen.SetUpApplyFlowAndLottery
        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:520)
        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:76)
        at scala.util.Try$.apply(Try.scala:210)
        at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:76)
        ... 21 common frames omitted
Wrapped by: java.lang.IllegalArgumentException: User defined Simulation class nextgen.SetUpApplyFlowAndLottery 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)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:91)
        at scala.Option.flatMap(Option.scala:283)
        at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:90)
        at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
        at scala.Option.getOrElse(Option.scala:201)
        at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
        at io.gatling.app.Selection$.apply(Selection.scala:36)
        at io.gatling.app.Runner.run0(Runner.scala:61)
        at io.gatling.app.Runner.run(Runner.scala:49)
        at io.gatling.app.Gatling$.start(Gatling.scala:87)
        at io.gatling.app.Gatling$.fromArgs(Gatling.scala:49)
        at io.gatling.app.Gatling$.main(Gatling.scala:38)
        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.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:53)
        at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:34)
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.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:53)
        at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:34)
Caused by: java.lang.IllegalArgumentException: User defined Simulation class nextgen.SetUpApplyFlowAndLottery 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)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:91)
        at scala.Option.flatMap(Option.scala:283)
        at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:90)
        at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
        at scala.Option.getOrElse(Option.scala:201)
        at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
        at io.gatling.app.Selection$.apply(Selection.scala:36)
        at io.gatling.app.Runner.run0(Runner.scala:61)
        at io.gatling.app.Runner.run(Runner.scala:49)
        at io.gatling.app.Gatling$.start(Gatling.scala:87)
        at io.gatling.app.Gatling$.fromArgs(Gatling.scala:49)
        at io.gatling.app.Gatling$.main(Gatling.scala:38)
        at io.gatling.app.Gatling.main(Gatling.scala)
        ... 6 more
Caused by: java.lang.ClassNotFoundException: nextgen.SetUpApplyFlowAndLottery
        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:520)
        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:76)
        at scala.util.Try$.apply(Try.scala:210)
        at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:76)
        ... 21 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.690 s
[INFO] Finished at: 2022-03-30T09:45:05-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:4.1.3:test (default-cli) on project nextgen-gatling: Gatling failed.: Process exited with an error: 255 (Exit value: 255) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

when i execute mvn gatling:test in the directory where is my pom.xml

(base) anthonyplaymithsanchez@Anthony-Playmith nextgen-gatling % mvn gatling:test
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< nextgen:nextgen-gatling >-----------------------
[INFO] Building nextgen-gatling 3.7.6
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> gatling-maven-plugin:4.1.3:test (default-cli) > test-compile @ nextgen-gatling >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ nextgen-gatling ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/anthonyplaymithsanchez/Documents/repos_schoolmint/nextgen-gatling/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ nextgen-gatling ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ nextgen-gatling ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ nextgen-gatling ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< gatling-maven-plugin:4.1.3:test (default-cli) < test-compile @ nextgen-gatling <<<
[INFO] 
[INFO] 
[INFO] --- gatling-maven-plugin:4.1.3:test (default-cli) @ nextgen-gatling ---
[ERROR] No simulations to run
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.512 s
[INFO] Finished at: 2022-03-30T09:47:34-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:4.1.3:test (default-cli) on project nextgen-gatling: No simulations to run -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Your scala-maven-plugin configuration is insufficient.
Please check the demo project for maven and Scala (link in the page @sbrevet provided).