Getting java.lang.IllegalArgumentException while creating docker Image which has Gatling

86 Views Asked by At

I'm trying to create docker Image of my scala project using sbt-native-packager.

The project also include Gatlings load test.

Gatlings load tests are working fine, but when I try to create it's docker image it throw an exception java.lang.IllegalArgumentException.

here is the detail:

build.sbt:

ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "2.13.4"

ThisBuild / scapegoatVersion := "1.4.8"


lazy val root = (project in file("."))
  .settings(
    name := "face-recognition"
  )

enablePlugins(GatlingPlugin, JavaAppPackaging, DockerPlugin, ScoverageSbtPlugin)
ocker / packageName := "face-recognition"

Docker / version := "0.0.1"
dockerExposedPorts := Seq(8080)

dockerChmodType := DockerChmodType.UserGroupWriteExecute
dockerPermissionStrategy := DockerPermissionStrategy.CopyChown
dockerAdditionalPermissions += (DockerChmodType.UserGroupPlusExecute, "/var/run/")

Docker / daemonUserUid := None
Docker / daemonUser := "root"

dockerBaseImage := "amazoncorretto:11-alpine3.18-jdk"

libraryDependencies ++= Seq(
"io.gatling.highcharts" % "gatling-charts-highcharts" % "3.9.1" % "test",
  "io.gatling" % "gatling-test-framework" % "3.9.1" % "test",
  "com.typesafe.akka" %% "akka-slf4j" % "2.8.0",
  "io.gatling" % "gatling-http" % "3.5.1"
)

plugin.sbt:

addSbtPlugin("io.gatling" % "gatling-sbt" % "4.2.6")

When I run command docker:publishLoca get an error:

[error] stack trace is suppressed; run last Gatling-it / enterprisePackage for the full output
[error] (Gatling-it / enterprisePackage) java.lang.IllegalArgumentException: Couldn't locate Gatling libraries in the classpath
1

There are 1 best solutions below

0
Zaryab Ali On

When you are trying to run it in docker, it is trying to run with:

GatlingIt / enterprisePackage

Which is causing the problem, because you have added simple library dependencies:

"io.gatling.highcharts" % "gatling-charts-highcharts" % "3.9.1" % "test",
  "io.gatling" % "gatling-test-framework" % "3.9.1" % "test"

Above dependencies are with "test" which works fine for simple Gatling / enterprisePackage (or in sbt 0.13 gatling:test). Now you need to add "it" in dependencies. Your updated dependencies are:

"io.gatling.highcharts" % "gatling-charts-highcharts" % "3.9.1" % "test,it",
      "io.gatling" % "gatling-test-framework" % "3.9.1" % "test,it"

Now these dependencies will add libraries for GatlingIt and you will be able to make image.

I hope above answer will work for you.