Class not found when running Kotlin simulation from JAR

Hi,
I’m getting java.lang.NoClassDefFoundError exceptions when trying to run simulations from a JAR file using the Gatling runner:

 gatling.bat -bf D:\work\testing\load\target\ -s load.simulation.ServiceTemplateSimulation

The simulation class itself is found, but there are errors resolving classes used inside the simulation:

java.lang.NoClassDefFoundError: load/config/SimulationConfig (wrong name: classes/load/config/SimulationConfig)
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
        at io.gatling.app.classloader.FileSystemBackedClassLoader.findClass(FileSystemBackedClassLoader.scala:76)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        at io.gatling.app.classloader.SimulationClassLoader.$anonfun$simulationClasses$2(SimulationClassLoader.scala:48)
        at scala.collection.immutable.List.map(List.scala:246)
        at scala.collection.immutable.List.map(List.scala:79)
        at io.gatling.app.classloader.SimulationClassLoader.simulationClasses(SimulationClassLoader.scala:48)
        at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:47)
        at scala.Option.getOrElse(Option.scala:201)
        at io.gatling.app.Selection$Selector.selection(Selection.scala:42)
        at io.gatling.app.Selection$.apply(Selection.scala:35)
        at io.gatling.app.Runner.run(Runner.scala:53)
        at io.gatling.app.Gatling$.start(Gatling.scala:92)
        at io.gatling.app.Gatling$.fromArgs(Gatling.scala:54)
        at io.gatling.app.Gatling$.main(Gatling.scala:42)
        at io.gatling.app.Gatling.main(Gatling.scala)

SimulationConfig is actually a Kotlin object, so I suspect this might be related to some missing Kotlin runtime libraries? Are there any particular things to be aware of when packaging the simulations with Maven?

As far as I can tell this is not a duplicate of Example Kotlin test from gatling.io tutorial failing to be found at runtime – in my case I package the code myself using Maven with the “regular” Kotlin Maven plugin.

Thanks a lot,
m.

Hi,

Why have you created this post in the Gatling Enterprise category?
Here, you’re trying to run locally with the Gatling bundle, not deploying on Gatling Enterprise.

Moved it, thanks for pointing this out :sweat_smile:

Also, please note that the existing bundle:

A couple of questions, then:

  1. Will the new, Maven-based wrapper support Kotlin simulations? Again, I’m not really sure how does using Kotlin might interfere with running the simulation, once the code is already compiled and packaged.
  2. What is the timeline for the 3.11 release?

Thanks!

Will the new, Maven-based wrapper support Kotlin simulations

No.
The bundle was created more than 10 years ago as a tool for beginners who are not familiar with build tools, in particular when running in a corporate network where you have to configure the build tool to cope with the corporate proxy or use the corporate maven repository.

Things have changed a lot since then:

  • we now emphasize Java. In particular, Gatling Scala should only be used by Scala developers.
  • maven and gradle both provide wrappers

With this target in mind, the new “bundle” will be a standalone distribution of a maven+java project.

If you’re a Kotlin user, you are definitely a developer and should use a gradle or maven project.

What is the timeline for the 3.11 release?

In a few weeks.

1 Like

I think it all comes down to my confusion as to whether programatically running Gatling from within a custom main function like this:

fun main(vararg args: String) {
    val simulationClass = resolveSimulationClass(args)
    val props = GatlingPropertiesBuilder()
        .simulationClass(simulationClass)
    Gatling.fromMap(props.build())
}

is in any way different from running Gatling using the bundle/Maven plugin/new wrapper.

The supported launchers are:

  • our maven, gradle and sbt plugins. The new bundle will boil down to launching ./mvnw gatling:test with prefetched maven binaries and Gatling dependencies.
  • the helpers we provide for launching from your IDE. This is where you got the inspiration for your custom main function but using it for something else is not guaranteed to work.
  • Gatling Enterprise

We can’t help with custom deployments, sorry.

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