繁体   English   中英

如何修复:java.lang.ClassNotFoundException: BasicSimulation for gradle gatlingRun 任务?

[英]How to fix: java.lang.ClassNotFoundException: BasicSimulation for gradle gatlingRun task?

我正在尝试通过 gradle 运行 gatling 任务。 我专门设置了我的 scala 源代码集,在运行 gatlingRun 之前运行 compileScala,但我一直收到错误: java.lang.ClassNotFoundException: BasicSimulation

如何正确设置 te 任务? build.gradle

plugins {
    id "com.github.lkishalmi.gatling" version "3.0.2"
}
repositories {
    mavenCentral()
}
apply plugin: 'java'
apply plugin: 'scala'

sourceSets {
    main {
        scala {
            srcDirs = ['src/gatling/simulations/']
        }
    }
}



dependencies {
    compile "io.gatling:gatling-core:3.0.2"
    compile "io.gatling:gatling-http:3.0.2"
    compile 'io.gatling.highcharts:gatling-charts-highcharts:3.0.2'
    compile 'org.scala-lang:scala-library:2.11.8'
}

gatling {
    simulations = {
        include "*.scala"
    }
}


Gradle 语法: gradlew compileScala gatlingRun -Dorg.gradle.java.home=C:\\Users\\saber.alex\\Documents\\jre1.8.0_91

错误:


> Task :gatlingRun
16:22:52.131 [main] INFO io.gatling.core.config.GatlingConfiguration$ - Gatling will try to use 'gatling.conf' as custom config file.
16:22:52.910 [GatlingSystem-akka.actor.default-dispatcher-2] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
16:22:54.045 [main] ERROR io.gatling.app.Gatling$ - Run crashed
java.lang.IllegalArgumentException: User defined Simulation class BasicSimulation could not be loaded
    at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:79)
    at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:84)
    at scala.Option.orElse(Option.scala:289)
    at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:84)
    at scala.Option.flatMap(Option.scala:171)
    at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:82)
    at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
    at scala.Option.getOrElse(Option.scala:121)
    at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
    at io.gatling.app.Selection$.apply(Selection.scala:36)
    at io.gatling.app.Runner.run0(Runner.scala:74)
    at io.gatling.app.Runner.run(Runner.scala:61)
    at io.gatling.app.Gatling$.start(Gatling.scala:74)
    at io.gatling.app.Gatling$.fromArgs(Gatling.scala:47)
    at io.gatling.app.Gatling$.main(Gatling.scala:39)
    at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: BasicSimulation
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:70)
    at scala.util.Try$.apply(Try.scala:209)
    at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:70)
    ... 15 common frames omitted

> Task :gatlingRun FAILED
3 actionable tasks: 3 executed

gatling 中存在与不断变化的源目录相关的错误。 https://github.com/gatling/gatling/issues/3301

尝试使用默认目录进行模拟。 它在 SBT 项目中对我有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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