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

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:

sbt version is 1.9.6 and scala version is 2.13.4.

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"

addCommandAlias("dockerImage", ";clean; reload; coverageOff; compile; docker:publishLocal")

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 dockerImage 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

Hi @Zaryab,

I could reproduce with following settings:

  • project/plugins.sbt:
    addSbtPlugin("io.gatling"     % "gatling-sbt"                        % "4.7.0")
    addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")
    
  • build.sbt:
    import com.typesafe.sbt.packager.docker.{DockerChmodType, DockerPermissionStrategy}
    
    enablePlugins(GatlingPlugin, JavaAppPackaging, DockerPlugin)
    Docker / packageName := "reproducer"
    Docker / version := "0.0.1"
    
    dockerChmodType := DockerChmodType.UserGroupWriteExecute
    dockerPermissionStrategy := DockerPermissionStrategy.CopyChown
    dockerAdditionalPermissions += (DockerChmodType.UserGroupPlusExecute, "/var/run/")
    Docker / daemonUserUid := None
    Docker / daemonUser := "root"
    dockerBaseImage := "amazoncorretto:11-alpine3.18-jdk"
    addCommandAlias("dockerImage", ";clean; reload; compile; docker:publishLocal")
    
    scalaVersion := "2.13.12"
    
    scalacOptions := Seq(
      "-encoding", "UTF-8", "-release:8", "-deprecation",
      "-feature", "-unchecked", "-language:implicitConversions", "-language:postfixOps")
    
    val gatlingVersion = "3.10.3"
    libraryDependencies += "io.gatling.highcharts" % "gatling-charts-highcharts" % gatlingVersion % "test"
    libraryDependencies += "io.gatling"            % "gatling-test-framework"    % gatlingVersion % "test"
    

I solved the issue by adding ,it to dependencies scopes.

Last 3 lines of my build.sbt:

val gatlingVersion = "3.10.3"
libraryDependencies += "io.gatling.highcharts" % "gatling-charts-highcharts" % gatlingVersion % "test,it"
libraryDependencies += "io.gatling"            % "gatling-test-framework"    % gatlingVersion % "test,it"

Cheers!

1 Like

Thanks a lot sbrevet. I really appreciate that. :grinning:

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