gatling

Gatling can't generate an html report


I built a fat jar with gatling, and when I run it everything is ok, but at the end I don't get an HTML file and have this error:

Parsing log file(s)...
Parsing log file(s) done in 0s.
Generating reports...
Exception in thread "main" java.lang.ExceptionInInitializerError
        at io.gatling.charts.report.ReportsGenerator.generateFor(ReportsGenerator.scala:56)
        at io.gatling.app.RunResultProcessor.generateReports(RunResultProcessor.scala:61)
        at io.gatling.app.RunResultProcessor.processRunResult(RunResultProcessor.scala:35)
        at io.gatling.app.Gatling$.start(Gatling.scala:102)
        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)
Caused by: java.lang.IllegalStateException: Couldn't find a ComponentLibrary implementation
        at io.gatling.charts.component.ComponentLibrary$.<clinit>(ComponentLibrary.scala:30)
        ... 7 more

What could be the problem here?

This is my build.sbt:

import sbtassembly.AssemblyKeys.assembly

enablePlugins(GatlingPlugin)

scalaVersion := "2.13.13"

scalacOptions := Seq(
  "-encoding", "UTF-8", "-release:8", "-deprecation",
  "-feature", "-unchecked", "-language:implicitConversions", "-language:postfixOps")

// 3.10.5
val gatlingVersion = "3.10.5"
libraryDependencies += "io.gatling.highcharts" % "gatling-charts-highcharts" % gatlingVersion //% "test,it"
libraryDependencies += "io.gatling"            % "gatling-test-framework"    % gatlingVersion //% "test,it"
libraryDependencies += "io.github.gatling-cql" % "gatling-cql" % "3.9.0-1"
libraryDependencies += "com.esri.geometry" % "esri-geometry-api" % "1.2.1"
libraryDependencies += "org.apache.tinkerpop" % "gremlin-core" % "3.5.3"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.5.3"
libraryDependencies += "com.datastax.oss" % "java-driver-core" % "4.14.1"
libraryDependencies += "com.datastax.oss" % "java-driver-query-builder" % "4.14.1"
libraryDependencies += "com.datastax.oss" % "java-driver-mapper-runtime" % "4.14.1"

mainClass in assembly := Some("com.example.CassandraSimulation2")

assemblyMergeStrategy in assembly := {
  case  PathList("META-INF", "native", "libnetty_tcnative_linux_x86_64.so") => MergeStrategy.last
  case PathList("META-INF", _*) => MergeStrategy.discard
  case "reference.conf" => MergeStrategy.concat
  case _                        => MergeStrategy.first
}

If I run it from sbt shell everything is fine, the report is generated, but running it from fat jar I get the error described above.

If I look inside the far jar file that I have built, I do see these files there:

io.gatling.charts.highcharts.component.ComponentLibraryImpl io.gatling.charts.component.ComponentLibrary


Solution

  • I eventually ended up just building a fat jar with gradle and everything works. Idk why sbt screws up in this case.

    So, I took this as a base project: https://github.com/gatling/gatling-gradle-plugin-demo-scala

    Added this plugin: id "com.github.johnrengelman.shadow" version "8.1.1"

    And this is how I built the fat jar in gradle:

    shadowJar {
        mergeServiceFiles('reference.conf')
    }