Gatling version: 3.9.5 (must be up to date)
Gatling flavor: java kotlin scala javascript typescript
Gatling build tool: maven gradle sbt bundle npm
I read the guidelines and how to ask a question topics.
I provided a SSCCE (or at least, all information to help the community understand my topic)
I copied output I observe, and explain what I think should be.
I am trying to build kafka load testing and run the application via main class. To remove the dependency on gradlew i am using gatling api. By giving command ./gradlew gatlingRun it is able to run but not via main class.
It is not able to load simulation class.
This is my build.gradle->
dependencies {
implementation 'io.gatling:gatling-core:3.9.5'
implementation 'io.gatling:gatling-app:3.9.5'
implementation 'io.gatling.highcharts:gatling-charts-highcharts:3.9.5'
implementation 'org.scala-lang:scala-library:2.13.14'
gatling 'org.galaxio:gatling-kafka-plugin_2.13:0.12.0'
}
gatling {
}
sourceSets {
gatling {
java {
srcDir 'src/gatling/java'
}
}
}
Service class
import io.gatling.app.Gatling;
import io.gatling.core.config.GatlingPropertiesBuilder;
public class GatlingService {
public void runKafkaSimulation() {
GatlingPropertiesBuilder props = new GatlingPropertiesBuilder();
props.simulationClass("com.project.loadtesting.KafkaSimulation");
try {
Gatling.fromMap(props.build());
} catch (Exception e) {
System.err.println("Failed to run Gatling simulation: " + e.getMessage());
e.printStackTrace();
}
}
}
Error:
22:00:34.950 [main] ERROR io.gatling.app.Gatling$ -- Run crashed
java.lang.IllegalArgumentException: User defined Simulation class com.finance.project.loadtesting.KafkaSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:84)