2.2.0 - java.lang.NoClassDefFoundError

I’m trying to do something brain-dead simple: run a one-off gatling script in the current directory from the command-line. In that directory, I have a gatling.conf file, like so:

gatling {

core {

directory {

results = “./results” # Name of the folder where all reports folder are located

data = “.” # Folder where user’s data (e.g. files used by Feeders) is located

bodies = “.” # Folder where bodies are located

simulations = “.” # Folder where the bundle’s simulations are located

binaries = “./target” # If set, name of the folder where compiles classes are located

}

}

}

The .scala file does not define a package. It is in the root of the defined simulations directory. The class does extend Simulation. It looks like this:

import io.gatling.core.Predef._

import io.gatling.http.Predef._

class RegisterUsers extends Simulation {

val FORM_POST_URL = “form-post-url”

val httpConf = http.baseURL( “” )

val process =

scenario( “Register Individual” )

.feed( tsv( “unregistered-individuals.txt” ) )

.exec( http( “Registration Page” )

.get( “/web/public/registration” )

.check( css( “form#form-info”, “action” ).saveAs( FORM_POST_URL ) ) )

.exec( session => {

print( session(FORM_POST_URL).as[String] )

session

})

setUp( process.inject( atOnceUsers(1) ).protocols( httpConf ))

}

I run gatling like this:

/data/software/gatling/bin/gatling.sh \

–simulation RegisterUsers

The output I get is:

GATLING_HOME is set to /data/software/gatling

Exception in thread “main” java.lang.NoClassDefFoundError: test-classes/RegisterUsers (wrong name: RegisterUsers)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at io.gatling.app.classloader.FileSystemBackedClassLoader.findClass(FileSystemBackedClassLoader.scala:71)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at io.gatling.app.classloader.SimulationClassLoader$$anonfun$simulationClasses$1.applyOrElse(SimulationClassLoader.scala:47)

at io.gatling.app.classloader.SimulationClassLoader$$anonfun$simulationClasses$1.applyOrElse(SimulationClassLoader.scala:47)

at scala.collection.immutable.List.collect(List.scala:295)

at io.gatling.app.classloader.SimulationClassLoader.simulationClasses(SimulationClassLoader.scala:47)

at io.gatling.app.Selection$Selector.loadSimulations(Selection.scala:61)

at io.gatling.app.Selection$Selector.selection(Selection.scala:39)

at io.gatling.app.Selection$.apply(Selection.scala:33)

at io.gatling.app.Gatling.runIfNecessary(Gatling.scala:73)

at io.gatling.app.Gatling.start(Gatling.scala:63)

at io.gatling.app.Gatling$.start(Gatling.scala:51)

at io.gatling.app.Gatling$.fromArgs(Gatling.scala:43)

at io.gatling.app.Gatling$.main(Gatling.scala:37)

at io.gatling.app.Gatling.main(Gatling.scala)

It appears to compile, because the target directory looks like this:

target

target/test-classes

target/test-classes/RegisterUsers.class

target/test-classes/RegisterUsers$$anonfun$1.class

target/zincCache

Any thoughts why Gatling can’t load and execute my class?

I think it’s a bug. When I comment out the binaries and let it use the default, it seems to find it just fine. Which means you have a configuration option that does not work if you actually set the option. :slight_smile:

Indeed a bug: https://github.com/gatling/gatling/issues/2802

Thanks for reporting!