Daniel Rodríguez
Daniel Rodríguez

Reputation: 11

Why gatling project don't work with maven?

I am starting with gatling, I have a project with maven with the latest versions of gatling and scala, I have already checked all the parameterization within the ide I have changed versions and nothing works

here show my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>gatling-poc</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>14</maven.compiler.source>
        <maven.compiler.target>14</maven.compiler.target>
        <encoding>UTF-8</encoding>

        <gatling.version>3.8.4</gatling.version>
        <gatling-maven-plugin.version>4.2.7</gatling-maven-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.gatling.highcharts</groupId>
            <artifactId>gatling-charts-highcharts</artifactId>
            <version>${gatling.version}</version>
        </dependency>
    </dependencies>

    <build>
        <testSourceDirectory>src/test/scala</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>${gatling-maven-plugin.version}</version>
            </plugin>
        </plugins>
    </build>
</project>
java.lang.ClassNotFoundException: io.gatling.core.check.FindCheckBuilder
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 25 common frames omitted
Wrapped by: java.lang.NoClassDefFoundError: io/gatling/core/check/FindCheckBuilder
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:340)
    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)
    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.run(Runner.scala:49)
    at io.gatling.app.Gatling$.start(Gatling.scala:91)
    at io.gatling.app.Gatling$.fromArgs(Gatling.scala:53)
    at io.gatling.app.Gatling$.main(Gatling.scala:41)
    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:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at io.gatling.plugin.util.MainWithArgsInFile.runMain(MainWithArgsInFile.java:53)
    at io.gatling.plugin.util.MainWithArgsInFile.main(MainWithArgsInFile.java:34)

How do I resolve this?

I hope your help, please

Upvotes: 1

Views: 1520

Answers (1)

St&#233;phane LANDELLE
St&#233;phane LANDELLE

Reputation: 6608

<testSourceDirectory>src/test/scala</testSourceDirectory> seems to indicate you want to write your Gatling Simulations in Scala.

But then you haven't configured the scala-maven-plugin to compile your Scala code.

java.lang.NoClassDefFoundError: io/gatling/core/check/FindCheckBuilder

This class no longer exists in modern Gatling version. There's no way you get this error if your code was indeed compiled with Gatling 3.8.4 in the classpath.

In short, because you haven't configured the scala-maven-plugin, your Scala code is not being recompiled after you upgraded your dependencies.

Please check the official samples (and generally speaking the official documentation):

Upvotes: 1

Related Questions