I'm trying to write a simulation and i want to be able to run the simulation. I get an error while trying to $mvn gatling:execute.
My pom has the following dependencies:
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-charts</artifactId>
<version>2.2.5</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-core</artifactId>
<version>2.2.5</version>
</dependency>
and the following plugins:
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<scalaVersion>2.12.3</scalaVersion>
</configuration>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>performanceTests</id>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<simulationClass>simulations.SimulationClass</simulationClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
This is the error that i came across:
12:50:36.313 [main][WARN ][ZincCompiler.scala:141] i.g.c.ZincCompiler$ -
Pruning sources from previous analysis, due to incompatible CompileSetup.
java.lang.ClassNotFoundException: io.gatling.app.Gatling
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:42)
at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
Included dependency:
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-app</artifactId>
<version>2.2.5</version>
</dependency>
But now i get a new error:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
Caused by: java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)V
at com.github.mnogu.gatling.mqtt.protocol.MqttProtocolOptionPart.<init>(MqttProtocol.scala:124)
at com.github.mnogu.gatling.mqtt.protocol.MqttProtocol$.apply(MqttProtocol.scala:24)
at com.github.mnogu.gatling.mqtt.protocol.MqttProtocolBuilder$.apply(MqttProtocolBuilder.scala:13)
at com.github.mnogu.gatling.mqtt.Predef$.mqtt(Predef.scala:9)
at simulations.SimulationClass.<init>(SimulationClass.scala:10)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at io.gatling.app.Runner.run0(Runner.scala:79)
at io.gatling.app.Runner.run(Runner.scala:64)
at io.gatling.app.Gatling$.start(Gatling.scala:59)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:43)
at io.gatling.app.Gatling$.main(Gatling.scala:35)
at io.gatling.app.Gatling.main(Gatling.scala)
...
Any leads regarding this problem would be of great help.
Thank you
Your error says that you are missing following dependency,
<!-- https://mvnrepository.com/artifact/io.gatling/gatling-app -->
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-app</artifactId>
<version>2.2.5</version>
</dependency>
Updated
Your second error is mainly because the jar file that your code refers at runtime is not the same jar file that is used at compile time. So make sure that you are using the same jar while compiling and while running.
For that, you can delete the dependent jar files, maven clean your project and recompile and run the program.