Gatling simulations packed in a jar with dependencies

Hi,

We are writing Gatling simulations using Eclipse. We are using a project structure as described in this wiki page: https://github.com/excilys/gatling/wiki/Development-environment

We would like to package the whole project as a stand alone jar (with dependencies) and run it everywhere we need it.

We are trying to package such a jar with maven-assembly-plugin but we are facing an error when running a simple ‘java -jar thehugejar-jar-with-dependencies.jar’:

Exception in thread “main” java.lang.RuntimeException: Can’t find the jar matching (.*compiler-interface-\d+.\d+.\d±sources.jar)$
at com.excilys.ebi.gatling.app.ZincCompiler$$anonfun$2.apply(ZincCompiler.scala:44)
at com.excilys.ebi.gatling.app.ZincCompiler$$anonfun$2.apply(ZincCompiler.scala:44)
at scala.Option.getOrElse(Option.scala:108)
at com.excilys.ebi.gatling.app.ZincCompiler$.jarMatching$1(ZincCompiler.scala:44)
at com.excilys.ebi.gatling.app.ZincCompiler$.setupZincCompiler(ZincCompiler.scala:52)
at com.excilys.ebi.gatling.app.ZincCompiler$.apply(ZincCompiler.scala:94)
at com.excilys.ebi.gatling.app.SimulationClassLoader$.fromSourcesDirectory(SimulationClassLoader.scala:34)
at com.excilys.ebi.gatling.app.Gatling$$anonfun$12.apply(Gatling.scala:89)
at com.excilys.ebi.gatling.app.Gatling$$anonfun$12.apply(Gatling.scala:89)
at scala.Option.getOrElse(Option.scala:108)
at com.excilys.ebi.gatling.app.Gatling.start(Gatling.scala:89)
at com.excilys.ebi.gatling.app.Gatling$.fromMap(Gatling.scala:54)
at com.excilys.ebi.gatling.app.Gatling$.runGatling(Gatling.scala:74)
at com.excilys.ebi.gatling.app.Gatling$.main(Gatling.scala:49)
at com.excilys.ebi.gatling.app.Gatling.main(Gatling.scala)

Gatling 1.5.2, Maven 3.0.4…

Could you please help us to solve this issue?

Thanks.

David

Hi,

It won’t work, sorry.
We depend on Zinc (Scala incremental compiler) for compiling simulations on the fly, and you have to feed it java.io.Files for its dependencies.

Hi,

An alternative solution that might work is to use the appassembler-maven-plugin in combination with the maven-assembly-plugin to create a zip file with all the original jar-dependencies. Appassembler will create a script to run Engine.class with the necessary classpath. You wouldn’t be able to run java -jar uberjar.jar but unzip simulation.zip && simulation/bin/simulation.sh isn’t that bad either.

Regards,
Frode

Hi,

I wasn’t aware of this appassembler-maven-plugin, thanks for the pointer Frode.

We’ll rework Gatling’s outer layer in M4 so that you can build this kind of standalone jar (this will be part of our work on our SBT plugin).
Note that you’ll have to:

  • ship pre-compiled simulations in order to by pass Zinc

  • force from the command line the one simulation you want to run in order to bypass Simulations discovery
    David, would this meet your needs (won’t be developed anytime soon though, I fear)?

Stéphane

In case someone is still interested, I was able to run packaged simulations by creating a run.sh in a maven assembly which does: java -Dgatling.core.disableCompiler=true -Dgatling.core.simulationClass=simulations.Base -cp .:lib -jar simulations.jar
The jar packaging is standard maven packaging, with scala source compiled with scala-maven-plugin.

But I can’t figure out how to make discovery work at all. (2.0.0-M3a), hardcoding simulation names is what I do for now.

Hi Jean-Philippe,

Thanks for your feedback.

Gatling’s discovery only works when compiling from Gatling: we just scan the directory containing the generated classes, searching for classes extending Simulation. We don’t want to scan the whole classpath, ending up loading the whole of it into the ClassLoader.

Cheers,

Stéphane

Very interestin. Can u tell me something more on the procedure?

Best

Massimiliano

Sure, give me some time and I’ll write a blog post about it.
JP

Would be great!

Jean-Philippe Melanson,

can you please write detailed instruction how you achieved this?

I tried to find some example how to do this, but I didn’t.

Regards,
Yuriy Seredyuk

Hi,

We would want to create a stand alone jar for a gatling project. Can somebody help with steps.

Gatling fat jars: https://blog.codecentric.de/en/2015/12/loadtesting-using-gatling-fatjars-and-influxdb/

Adrian - Thanks for the pointer. This worked like a charm