The requested class is not in classpath or does not extends Simulation

3,713 views
Skip to first unread message

Ulrik Skyt

unread,
Mar 25, 2015, 11:57:26 AM3/25/15
to gat...@googlegroups.com

I am trying to upgrade to Gatling 2.1, but I'm stuck because I get this error when running gatling.sh:

The requested class('XxxYyyZzz') can not be found in the classpath or does not extends Simulation.
Choose a simulation number:
     [0] computerdatabase.BasicSimulation
     [1] computerdatabase.advanced.AdvancedSimulationStep01
     [2] computerdatabase.advanced.AdvancedSimulationStep02
     [3] computerdatabase.advanced.AdvancedSimulationStep03
     [4] computerdatabase.advanced.AdvancedSimulationStep04
     [5] computerdatabase.advanced.AdvancedSimulationStep05

I tried echo'ing the $GATLING_CLASSPATH used in gatling.sh and it does include a directory where my compiled simulation script (here named 'XxxYyyZzz') is present in the form of a XxxYyyZzz.class file as well as a number of class files for inner classes etc.

The classpath is quite long, so I tried placing this particular directory in front, in case it was because the path was too long, but that didn't change anything!

My invocation looks like this:

/path/to/gatling-charts-highcharts-bundle-2.1.4/bin/gatling.sh --simulation XxxYyyZzz --results-folder "$HERE/reports --data-folder "$HERE/data"


Any suggestions would be appreciated!!


Best regards
Ulrik

Stéphane LANDELLE

unread,
Mar 25, 2015, 12:13:10 PM3/25/15
to gat...@googlegroups.com
Are you sure you don't miss the package?
Then, please provide a reproducer.

Stéphane Landelle
Lead developer


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ulrik Skyt

unread,
Mar 25, 2015, 2:49:33 PM3/25/15
to gat...@googlegroups.com
My class does not declare a package.
I actually tried adding a package in the scala file - and on the startup parameters - that changed nothing.

I guess you're right, I should look into trying a minimal example and go from there...

/Ulrik

Ulrik Skyt

unread,
Mar 26, 2015, 3:13:59 AM3/26/15
to gat...@googlegroups.com
I tried copying the quickstart example to my performancetest/src folder:

package computerdatabase  // 1

import io.gatling.core.Predef._ // 2
import io.gatling.http.Predef._
import scala.concurrent.duration._

class MyBasicSimulation extends Simulation { // 3

  val httpConf = http // 4
    .baseURL("http://computer-database.herokuapp.com") // 5
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // 6
    .doNotTrackHeader("1")
   
.acceptLanguageHeader("en-US,en;q=0.5")
   
.acceptEncodingHeader("gzip, deflate")
   
.userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0")

 
val scn = scenario("BasicSimulation") // 7
    .exec(http("request_1")  // 8
    .get("/")) // 9
    .pause(5) // 10

  setUp( // 11
    scn.inject(atOnceUsers(1)) // 12
  ).protocols(httpConf) // 13
}


Then I compiled it with this command:

java -cp "$GATLING_HOME/lib/*" -Dscala.home="$GATLING_HOME/lib" -Dscala.usejavacp=true scala.tools.nsc.Main src/MyBasicSimulation.scala


Class files are now placed under my performancetest/computerdatabase/ folder:

>  ls performancetest/computerdatabase/
MyBasicSimulation.class

I modified the gatling.sh script to echo "$GATLING_CLASSPATH" the classpath just before invoking the Gatling class with a java command. This is my output:

GATLING_HOME is set to /products/gatling-charts-highcharts-bundle-2.1.4
Run compiler
Run Gatling
/products/gatling-charts-highcharts-bundle-2.1.4/lib/*:/products/gatling-charts-highcharts-bundle-2.1.4/user-files:/products/gatling-charts-highcharts-bundle-2.1.4/conf:/Users/usk/Work/FMK/fmk-recept/performancetest
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Xmx2048m
The requested class('computerdatabase.MyBasicSimulation') can not be found in the classpath or does not extends Simulation.
Choose a simulation number:
     [0] computerdatabase.BasicSimulation
     [1] computerdatabase.advanced.AdvancedSimulationStep01
     [2] computerdatabase.advanced.AdvancedSimulationStep02
     [3] computerdatabase.advanced.AdvancedSimulationStep03
     [4] computerdatabase.advanced.AdvancedSimulationStep04
     [5] computerdatabase.advanced.AdvancedSimulationStep05
^C


What am I missing?

/Ulrik


On Wednesday, March 25, 2015 at 5:13:10 PM UTC+1, Stéphane Landelle wrote:

slan...@gatling.io

unread,
Mar 26, 2015, 3:16:23 AM3/26/15
to gat...@googlegroups.com
Why don't you let Gatling do the compiling job?


Ulrik Skyt

unread,
Mar 26, 2015, 3:39:32 AM3/26/15
to gat...@googlegroups.com

I tried the basic example again (with the src in a new folder separate from my previous attempts), and let gatling do the compiling itself and that worked fine!

But trying the same with my own Simulation classes, which make use of a lot of Java code references in the JAVA_CLASSPATH gave compile errors (.

Therefore I tried modifying gatling.sh with this line:

COMPILATION_CLASSPATH=$COMPILATION_CLASSPATH:$JAVA_CLASSPATH

... and the it all worked for my code too!

That must be an error in the gatling.sh script, or perhaps in the ZincCompiler, right?

Stéphane LANDELLE

unread,
Mar 26, 2015, 4:00:49 AM3/26/15
to gat...@googlegroups.com
That's a bug in our compiler module that's ignoring java files.
I'll fix this, you shouldn't have to compile yourself.

Stéphane Landelle
Lead developer


--

Ulrik Skyt

unread,
Apr 21, 2015, 8:01:52 AM4/21/15
to gat...@googlegroups.com

It seems this fix didn't make into Gatling 2.1.5, right?

/Ulrik

Stéphane LANDELLE

unread,
Apr 27, 2015, 5:48:57 AM4/27/15
to gat...@googlegroups.com
Yes it did: https://github.com/gatling/gatling/issues/2640

Do you still have an issue? If so, can you share a reproducer please?

Stéphane Landelle
Lead developer


Ulrik Skyt

unread,
Apr 27, 2015, 6:50:35 AM4/27/15
to gat...@googlegroups.com
I still have an issue, yes.

It seems your fix has to do with the scala compiler including .java files.

I am trying to compile with my already compiled .class files in the JAVA_CLASSPATH.

My local fix is to add this line in gatling.sh, just before "# Run the compiler":

COMPILATION_CLASSPATH=$COMPILATION_CLASSPATH:$JAVA_CLASSPATH

/Ulrik

Stéphane LANDELLE

unread,
Apr 28, 2015, 5:00:38 AM4/28/15
to gat...@googlegroups.com

Stéphane Landelle
Lead developer


Reply all
Reply to author
Forward
0 new messages