2

我正在使用 gatling-maven-plugin 运行一些性能测试。我只是按照官方文档http://gatling.io/docs/2.2/extensions/maven_plugin/

我有这个配置

<!--PERFORMANCE TEST-->
        <plugin>
            <groupId>io.gatling</groupId>
            <artifactId>gatling-maven-plugin</artifactId>
            <version>2.2.4</version>
            <configuration>
                <!--<disableCompiler>true</disableCompiler>-->
                <configFolder>${project.basedir}/src/test/resources</configFolder>
                <dataFolder>${project.basedir}/src/test/resources/data</dataFolder>
                <resultsFolder>${project.basedir}/target/gatling/results</resultsFolder>
                <bodiesFolder>${project.basedir}/src/test/resources/bodies</bodiesFolder>
                <simulationsFolder>${project.basedir}/src/test/scala/performance/</simulationsFolder>
                <runDescription>This-is-the-run-description</runDescription>
                <simulationClass>${project.basedir}\src\test\scala\performance\TillScenario</simulationClass>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

它抱怨是因为

error: java.lang.NoClassDefFoundError: scala/reflect/internal/AnnotationInfos$ErroneousAnnotation$
        at scala.tools.nsc.typechecker.Typers$class.newTyper(Typers.scala:100)
        at scala.tools.nsc.Global$$anon$1.newTyper(Global.scala:463)
        at scala.tools.nsc.typechecker.Namers$Namer.<init>(Namers.scala:58)
        at scala.tools.nsc.typechecker.Namers$NormalNamer.<init>(Namers.scala:50)
        at scala.tools.nsc.typechecker.Namers$class.newNamer(Namers.scala:51)
        at scala.tools.nsc.Global$$anon$1.newNamer(Global.scala:463)
        at scala.tools.nsc.typechecker.Analyzer$namerFactory$$anon$1.apply(Analyzer.scala:43)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:441)
        at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:432)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:441)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:399)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:399)
        at scala.collection.Iterator$class.foreach(Iterator.scala:750)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
        at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:399)
        at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1500)
        at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1487)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:1482)
        at scala.tools.nsc.Global$Run.compile(Global.scala:1580)
        at scala.tools.nsc.Driver.doCompile(Driver.scala:32)
        at scala.tools.nsc.MainClass.doCompile(Main.scala:23)
        at scala.tools.nsc.Driver.process(Driver.scala:51)
        at scala.tools.nsc.Main.process(Main.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at sbt.compiler.RawCompiler.apply(RawCompiler.scala:33)
        at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1$$anonfun$apply$2.apply(AnalyzingCompiler.scala:146)
        at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1$$anonfun$apply$2.apply(AnalyzingCompiler.scala:142)
        at sbt.IO$.withTemporaryDirectory(IO.scala:344)
        at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1.apply(AnalyzingCompiler.scala:142)
        at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1.apply(AnalyzingCompiler.scala:139)
        at sbt.IO$.withTemporaryDirectory(IO.scala:344)
        at sbt.compiler.AnalyzingCompiler$.compileSources(AnalyzingCompiler.scala:139)
        at sbt.compiler.IC$.compileInterfaceJar(IncrementalCompiler.scala:58)
        at com.typesafe.zinc.Compiler$.compilerInterface(Compiler.scala:148)
        at com.typesafe.zinc.Compiler$.create(Compiler.scala:53)
        at io.gatling.compiler.ZincCompiler$delayedInit$body.apply(ZincCompiler.scala:147)
        at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
        at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
        at scala.App$$anonfun$main$1.apply(App.scala:71)
        at scala.App$$anonfun$main$1.apply(App.scala:71)
        at scala.collection.immutable.List.foreach(List.scala:318)
        at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
        at scala.App$class.main(App.scala:71)
        at io.gatling.compiler.ZincCompiler$.main(ZincCompiler.scala:36)
        at io.gatling.compiler.ZincCompiler.main(ZincCompiler.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
        at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
Caused by: java.lang.ClassNotFoundException: scala.reflect.internal.AnnotationInfos$ErroneousAnnotation$
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 54 more

如果我在配置中添加这一行

<disableCompiler>true</disableCompiler>

投诉是因为找不到我的模拟类

Caused by: java.lang.IllegalArgumentException: The requested class 'path\TillScenario' can not be found in the classpath or does not extends Simulation.

知道我在做什么错吗?

4

2 回答 2

5

不确定您是否在禁用后添加了Scala Maven 插件gatling-maven-plugin,但这可能解释了第二个错误,如此所述。Simulation您应该通过 Gatling 插件或 Scala 插件以某种方式编译您的类。

至于第一个错误,它看起来像是依赖不匹配问题。确保您使用的是二进制兼容版本的 Gatling 依赖项以及 Scala 依赖项。

我希望这是有帮助的。

于 2017-04-20T18:43:29.293 回答
1

我通过将 scala 库版本从 2.11.6 更新到 2.11.8 来解决

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.11.8</version>
    </dependency>
于 2018-06-04T12:51:11.417 回答