Getting Class Not Found Error When Running Test Using Maven

No idea what could be causing this, was able to run tests fine this morning, and all I’ve done is move some folders around to organize my tests better. I did update the simulationsFolder.

POM:

<plugin>
    <groupId>io.gatling</groupId>
    <artifactId>gatling-maven-plugin</artifactId>
    <version>${gatling.plugin.version}</version>
    <configuration>
        <simulationsFolder>src/test/java/tests/performance</simulationsFolder>
    </configuration>
</plugin>

FOLDER STRUCTURE:
Auto Generated Inline Image 1.png

CLI COMMAND:




<br>$ mvn clean test gatling:test -Dgatling.simulationClass=get_sites_baseline<br>


ERROR:

Can you please try adding the below
Can you also add goals and execute using the maven gatling goals.

So basically the particular section would look like


io.gatling
gatling-maven-plugin
2.2.1

src/test/java/tests
servicerequests.get_service_requests_instance_baseline




integration-test



and the command to execute should be as below

mvn clean install gatling:integration-test

I had tried that, but not ideal as I don’t want my POM to require adding a line for every performance test we run. Was able to get things working by adding a “runner” object file, and this also allows me to debug in IntelliJ.

package tests.performance.sites

import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder

object SitesRunner {

  def main(args: Array[String]): Unit = {

    val simClass = classOf[get_sites_baseline].getName

    val props = new GatlingPropertiesBuilder
    props.simulationClass(simClass)

    Gatling.fromMap(props.build)
  }

}

If you’re not familiar with Java and maven, instead of trying to change the layout, you’d better stick to the default one, like what you can find in our demo: https://github.com/gatling/gatling-maven-plugin-demo

So I created a new repo, based on the demo project you listed, but not seeing any syntax highlighting for my variables, and my java file now has a weird icon(using IntelliJ). Wondering if something is missing from my POM? Using Java 11 since it’s latest LTS, and saw it’s supposed to be supported.

You probably haven’t installed the Scala plugin for IntelliJ.

I already had it installed, was required for my original Karate/Gatling project. Scala SDK is also installed, using 2.12.7

Have you correctly imported project as a maven one?

• make sure JDK is properly configured
• maybe for maven project reimport

Yes, imported as Maven. Tried removing and re-importing. JDK is set to 11. Will continue trying to troubleshoot.

Maybe something in my POM:

<properties>
  <maven.compiler.source>11.2</maven.compiler.source>
  <maven.compiler.target>11.2</maven.compiler.target>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <gatling.version>3.0.3</gatling.version>
  <gatling-plugin.version>3.0.2</gatling-plugin.version>
</properties>

Revert your change regarding maven source and target version (1.8 in our demo).

Got things working, seems the folders needed to be re-mapped to source in my IDE. But for some reason the io.gatling dependencies are not automatically available to import in the scala files. For example I had to add gatling-http, but before it was automatically available.

But are you saying Java 11 is not supported, only 8?

No, Gatling works perfectly fine with the Java 11 runtime.
And our demo project works out of the box.

The source option is about the Java APIs you want to use and the target one is about the bytecode version you want to emit. The Scala compiler doesn’t support emitting Java 11 bytecode yet.

Your problems come from your modifications, you’d save you a lot of pain if you were to stick to the defaults.