简体   繁体   中英

Gatling Error Exception in thread "main" java.lang.NoClassDefFoundError: io/gatling/charts/component/impl/ComponentLibraryImpl

Im New To Gatling Load Testing.

1.Program run from Run configuration throwing error No goal Found to execute for following In Goal

gatling:test -Dgatling.simulationClass=RestAPITest.GetRequest.scala

2.Projects are running from Scala Engine But Charts are not generation error exception message like as fallows Exception in thread "main" java.lang.NoClassDefFoundError: io/gatling/charts/component/impl/ComponentLibraryImpl

在此处输入图片说明

//Test code as follows

<?xml version="1.0"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>WOW_CT_PT</groupId>

    <artifactId>WOW_CT_PT</artifactId>

    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <scala.version>2.12.10</scala.version>
        <gatling.version>3.3.1</gatling.version>
    </properties>

    <repositories>
        <repository>
            <id>scala-tools.org</id>
            <name>Scala-Tools Maven2 Repository</name>
            <url>http://scala-tools.org/repo-releases</url>
        </repository>
    </repositories>

    <dependencies>
    <dependency>
      <groupId>io.gatling</groupId>
      <artifactId>gatling-test-framework</artifactId>
      <version>3.3.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.gatling/gatling-core -->
    <dependency>
      <groupId>io.gatling</groupId>
      <artifactId>gatling-core</artifactId>
      <version>3.3.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.gatling.highcharts/gatling-highcharts -->
    <dependency>
      <groupId>io.gatling.highcharts</groupId>
      <artifactId>gatling-highcharts</artifactId>
      <version>3.3.1</version>
      <type>pom</type>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.gatling.highcharts/gatling-charts-highcharts -->
<dependency>
    <groupId>io.gatling.highcharts</groupId>
    <artifactId>gatling-charts-highcharts</artifactId>
    <version>3.4.0</version>
</dependency>   
    </dependencies>

    <build>
        <testSourceDirectory>src/test/scala</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.3.1</version>
                <configuration>
                    <scalaVersion>2.11.8</scalaVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>2.2.3</version>
                <executions>
                    <execution>
                        <id>performanceTests</id>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <simulationClass>simulations.SimulationClass</simulationClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>


import io.gatling.core.Predef._

import io.gatling.http.Predef._

class GetRequest extends Simulation {

    val httpProtocol = http
        .baseUrl("http://dummy.restapiexample.com/") // Here is the root for all relative URLs

    val scn = scenario(scenarioName = "Axiom gate request")
        .exec(http(requestName = "get request")
            .get("api/v1/employees")
        )
        .pause(duration = 5)

    setUp(
        scn.inject(atOnceUsers(users = 1))
    ).protocols(httpProtocol)
}

After the error message I assume that you have not imported the dependency gatling-charts-highcharts . You can add it to Maven:

<dependency>
    <groupId>io.gatling.highcharts</groupId>
    <artifactId>gatling-charts-highcharts</artifactId>
    <version>3.3.1</version>
</dependency>

Just adapt the version number to your current version of gatling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM