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()
}
}
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. .
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: