Exception in thread "main" java.lang.NoClassDefFoundError: io/gatling/javaapi/core/Simulation

I have the scala code that sends message request to sqs. This was working like 3 weeks ago but now when I run it. I encountered the error below. Kindly help. Thank you.

Exception in thread "main" java.lang.NoClassDefFoundError: io/gatling/javaapi/core/Simulation
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at io.gatling.app.classloader.FileSystemBackedClassLoader.findClass(FileSystemBackedClassLoader.scala:71)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at io.gatling.app.classloader.SimulationClassLoader.$anonfun$simulationClasses$2(SimulationClassLoader.scala:48)

My scala code below:

package frontline.sample

import com.amazonaws.auth.AWSStaticCredentialsProvider
import com.amazonaws.auth.BasicSessionCredentials
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.regions.Regions
import com.amazonaws.services.sqs.model.SendMessageRequest
import com.amazonaws.services.sqs._
import io.gatling.core.Predef._
import io.gatling.core.scenario.Simulation
import io.gatling.core.structure.ScenarioBuilder
import scala.language.postfixOps

class US_214 extends Simulation {

  val devQueueUrl = "url"
  val endpoint = "endpoint"
  val accessKey = "accesskey"
  val secretKey = "secretkey"
  val session_token = "token"
  val batchSize = 10
  val messageBody = "{\n  \"Type\": \"Notification\",\n  \"MessageId\": ...}")
  val awsCreds = new BasicSessionCredentials(accessKey, secretKey, session_token)
  var client: AmazonSQS = AmazonSQSClientBuilder
    .standard()
    .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
    .withEndpointConfiguration(new EndpointConfiguration(endpoint, Regions.EU_WEST_1.getName)) // update region if needed sqs fifo queue
    .build()


  val scn: ScenarioBuilder = scenario("SQS Perf Test")
    .exec(session => {
      val request =
        new SendMessageRequest(devQueueUrl, messageBody)
      client.sendMessage(request)
      session
    }
    )


  setUp(
    scn.inject(
      constantUsersPerSec (1) during (1) // 22,589 appartements: processed daily
      //constantUsersPerSec (5) during (3600) //max of 15300 classifieds per hour
    ) // 1M
    //constantUsersPerSec (300) during (333 seconds) // 1M
    //              constantUsersPerSec(300) during (160 seconds) // 0.5M
    //constantUsersPerSec (100) during (10 seconds) // 10K
    // other example: Let's have 10 regular users and 2 admins, and ramp them over 10 seconds so we don't hammer
    // the server
    //users.inject(rampUsers(10).during(10)), admins.inject(rampUsers(2).during(10))
  ).protocols()

  after {
    client.shutdown()
  }
}

How is this test executed?
There’s a mention of frontline, are you executing on Gatling Enterprise self hosted?

Hi I am executing it by using the play button through the application which has the configuration setting.

and together with the package object that has this code.

I am a bit new on using Gatling and scala so Im still groping on stuffs.

This was working before like 3 weeks ago, then when I run it now, the error is shown. I thought at first maybe the Gatling repository I used has some updates but when I try it on the other public gatling repo we have, same error. I am thinking maybe something happened on my local files (java, jar, sbt, etc) which the repository might be checking during build, compilation…I dont know and understand the real cause behind. .

this is the public repo I used: GitHub - gatling/gatling: Modern Load Testing as Code
the pom xml used is:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         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>test</groupId>
    <artifactId>gatling-parent</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <dependencies>
        <dependency>
            <groupId>io.gatling.highcharts</groupId>
            <artifactId>gatling-charts-highcharts</artifactId>
            <version>${gatling.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-lambda-java-core</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-lambda-java-events</artifactId>
            <version>2.2.5</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.499</version>
        </dependency>
        <dependency>
            <groupId>io.gatling</groupId>
            <artifactId>gatling-core</artifactId>
            <version>${gatling.version}</version>
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.12.8</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.gatling/gatling-http -->
        <dependency>
            <groupId>io.gatling</groupId>
            <artifactId>gatling-http</artifactId>
            <version>${gatling.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.gatling/gatling-app -->
        <dependency>
            <groupId>io.gatling</groupId>
            <artifactId>gatling-app</artifactId>
            <version>${gatling.version}</version>
        </dependency>

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>amazon-sqs-java-messaging-lib</artifactId>
            <version>1.0.4</version> <!-- latest version at the time of this post -->
        </dependency>

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-sqs</artifactId>
            <version>1.11.497</version> <!-- latest version at the time of this post -->
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.1000</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>sts</artifactId>
            <version>2.15.13</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
            <version>2.15.13</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>sns</artifactId>
            <version>2.15.13</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>3.3.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.6.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>3.0.1</version>
            </plugin>
        </plugins>
    </build>
    
</project>

@sbrevet may I also seek your help?

Firest, what are you doing with the Gatling sources???

Then Gatling 3.0.3 is from 4.5 years ago, obviously it’s completely outdated and incompatible.

Finally, GatlingRunner is something in-house, not an official component.

You should probably stick to the official ways to use Gatling, as described in the documentation and the online trainings.

When you mean Gatling sources, what are those? Im not technically adept on jargons.

The error Exception in thread “main” java.lang.NoClassDefFoundError: io/gatling/javaapi/core/Simulation, does this mean it cant find this folder path?

Though, this way of running is working fine on my colleague workstation. I did not touch this code for 3 weeks. I used it before for testing and simulating sending thousands of sqs requests. Now, it suddenly giving me this error.

Already resolved. I changed the folder structure of my test to package, then moved object package, 2 classes (API_classified and US_214) under it. Then run it using the modified configuration of Application Gatling runner:

So your GatlingRunner is just the official Engine helper.
IMO, you should stick to the standard sample projects.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.