When I run a very simple simulation, I get this (with gatling 2.0 SNAPSHOT):
Exception in thread “main” java.lang.NoClassDefFoundError: io/gatling/charts/component/impl/ComponentLibraryImpl
at io.gatling.charts.component.ComponentLibrary$.(ComponentLibrary.scala:42)
at io.gatling.charts.component.ComponentLibrary$.(ComponentLibrary.scala)
at io.gatling.charts.report.ReportsGenerator$.generateFor(ReportsGenerator.scala:44)
at io.gatling.app.Gatling.generateReports$1(Gatling.scala:170)
…
Analysis:
I downloaded the source code for gatling. The class file in question is in the source, but not in the compiled jar.
In the source code of gatlng there is this class that never makes it to the jar file with a clear explanation if you know Scala (I don’t) about it being a mock class.
package io.gatling.charts.component.impl
/**
- Mock implementation that is removed from the binary.
- A unique implementation is expected to be present in the classpath.
*/
class ComponentLibraryImpl extends ComponentLibrary {
GOAL:
I am trying to run gatling from a gradle script. Scratch that… I am trying to get Gatling 2.0 SNAPSHOT to run somehow, some way.
Gatling and Gradle Example based on this blog post about Load Testing in Gradle with Gatling.
A good friend of mine gave me A LOT OF GATLING 2.0 SCRIPTS for a project and the example from the blog was of course Gatling 1.5.
1.5 != 2.0
The 2.0 that is on the website is incompatible with the scripts my friend gave me. He says it is what is in github currently is what is needed.
I am just trying to get some simulations to run and generate a report. Basic stuff. I am new to Gatling.
After hours, screwing around with sbt and gradle, I was able to get something running, but the error above. The closest I got was calling it from gradle. The build for the dist seems to be horked or I don’t know sbt that well or both.
Running sbt dist generates a zip file with no jar files. So one that does not run. The 2.0 from the site, does not work with the 2.0 scripts that I have.
This is not the actual project. The actual project I can’t share, but this is the same error message. A small test case.
I created a little sample project here:
Sample project
I have a vertx verticle (more or less like a servlet).
public class ExampleVerticle extends Verticle {
private final String CONTENT_TYPE_KEY = “Content-Type”;
private final String CONTENT_TYPE_VALUE = “text/html; charset=UTF-8”;
private String message = “\nHi Mom!\n”;
public void start() {
HttpServer server = vertx.createHttpServer();
server.requestHandler(new Handler() {
public void handle(final HttpServerRequest request) {
doGet(request);
}
});
server.listen(8080);
}
void doGet(HttpServerRequest request) {
request.response().headers().add(CONTENT_TYPE_KEY, CONTENT_TYPE_VALUE);
request.response().setStatusCode(200).end(
this.message
);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
The Gatling test is here:
package com.example
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.http.HeaderNames._
import io.gatling.http.HeaderValues._
import io.gatling.core.scenario.Simulation
import io.gatling.http.Predef._
import io.gatling.core.Predef._
import io.gatling.http.HeaderNames._
import io.gatling.http.HeaderValues._
import scala.concurrent.duration._
class ExampleVerticleLoadTest extends Simulation {
val httpProtocol = http
.baseURL(System.getProperty(“HOST_UNDER_TEST”, “http://localhost:8080/”))
val scn = scenario(“ExampleVerticle”)
.exec(http(“Get Hello World”).get("/"))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
So basically… Hello World.
Running:
You run vertx like this btw
$ ./gradlew clean compileJava modZip runMod
You run gatling like this:
$ ./gradlew load
OUTPUT:
Simulation com.example.ExampleVerticleLoadTest started…
18:21:37.901 [GatlingSystem-akka.actor.default-dispatcher-2] INFO io.gatling.http.config.HttpProtocol - Start warm up
18:21:37.925 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG o.j.n.c.socket.nio.SelectorUtil - Using select timeout of 500
18:21:37.925 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG o.j.n.c.socket.nio.SelectorUtil - Epoll-bug workaround enabled = false
18:21:37.991 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG o.j.n.channel.DefaultChannelFuture - The dead lock checker in DefaultChannelFuture has been disabled as requested at your own risk.
18:21:38.041 [GatlingSystem-akka.actor.default-dispatcher-2] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
Non cached request
DefaultHttpRequest(chunked: false)
GET /xUrsE HTTP/1.1
Host: goo.gl
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: en-US,en;q=0.5
Connection: keep-alive
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0
using Channel
[id: 0xc5bb3a41, /0:0:0:0:0:0:0:1:63255 => goo.gl/74.125.224.224:80]
18:21:38.230 [New I/O worker #2] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
Request DefaultHttpRequest(chunked: false)
GET /xUrsE HTTP/1.1
Host: goo.gl
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: en-US,en;q=0.5
Connection: keep-alive
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0
Response DefaultHttpResponse(chunked: false)
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Location: http://gatling-tool.org/
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 80:quic
Content-Length: 206
18:21:38.231 [New I/O worker #2] DEBUG c.n.h.c.p.netty.NettyConnectionsPool - Adding uri: http://goo.gl:80 for channel [id: 0xc5bb3a41, /0:0:0:0:0:0:0:1:63255 => goo.gl/74.125.224.224:80]
18:21:38.232 [GatlingSystem-akka.actor.default-dispatcher-2] INFO io.gatling.http.config.HttpProtocol - Warm up done
18:21:38.243 [GatlingSystem-akka.actor.default-dispatcher-2] INFO i.gatling.core.controller.Controller - Total number of users : 1
18:21:38.294 [GatlingSystem-akka.actor.default-dispatcher-3] INFO i.g.c.result.writer.FileDataWriter - Initializing
18:21:38.294 [GatlingSystem-akka.actor.default-dispatcher-10] INFO i.g.c.r.writer.ConsoleDataWriter - Initializing
18:21:38.296 [GatlingSystem-akka.actor.default-dispatcher-3] INFO i.g.c.result.writer.FileDataWriter - Initialized
18:21:38.296 [GatlingSystem-akka.actor.default-dispatcher-10] INFO i.g.c.r.writer.ConsoleDataWriter - Initialized
18:21:38.299 [GatlingSystem-akka.actor.default-dispatcher-11] DEBUG i.gatling.core.controller.Controller - Launching All Scenarios
18:21:38.303 [GatlingSystem-akka.actor.default-dispatcher-11] DEBUG i.gatling.core.controller.Controller - Finished Launching scenarios executions
18:21:38.303 [GatlingSystem-akka.actor.default-dispatcher-11] DEBUG i.gatling.core.controller.Controller - Setting up max duration
18:21:38.304 [GatlingSystem-akka.actor.default-dispatcher-11] INFO i.gatling.core.controller.Controller - Start user #554931357585131387-0