java .lang.NoClassDefFoundError: com.trueaccord.scalapb.GeneratedEnum с плагином Gatling Maven - PullRequest
0 голосов
/ 29 апреля 2020

Использование последней версии OpenJDK 11.0.7 с плагином Gatling Maven приводит к этой сборке cra sh. Я попытался удалить локальные папки репозитория Maven для Gatling, scala -lang и scala -sbt и повторно запустить чистую установку. Ниже я вставил свой пом. xml. Может кто-нибудь помочь решить эту проблему?

java.lang.ClassNotFoundException: com.trueaccord.scalapb.GeneratedEnum
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:766)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1078)
    ... 31 common frames omitted
Wrapped by: java.lang.NoClassDefFoundError: com.trueaccord.scalapb.GeneratedEnum
    at java.base/java.lang.ClassLoader.defineClassImpl(Native Method)
    at java.base/java.lang.ClassLoader.defineClassInternal(ClassLoader.java:476)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:437)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:1110)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:898)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:806)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:764)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1078)
    at sbt.internal.inc.FileAnalysisStore$BinaryFileStore.<init>(FileAnalysisStore.scala:50)
    at sbt.internal.inc.FileAnalysisStore$.binary(FileAnalysisStore.scala:36)
    at io.gatling.compiler.ZincCompiler$.doCompile(ZincCompiler.scala:174)
    at io.gatling.compiler.ZincCompiler$.delayedEndpoint$io$gatling$compiler$ZincCompiler$1(ZincCompiler.scala:216)
    at io.gatling.compiler.ZincCompiler$delayedInit$body.apply(ZincCompiler.scala:39)
    at scala.Function0.apply$mcV$sp(Function0.scala:39)
    at scala.Function0.apply$mcV$sp$(Function0.scala:39)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
    at scala.App.$anonfun$main$1$adapted(App.scala:80)
    at scala.App$$Lambda$5/0000000000000000.apply(Unknown Source)
    at scala.collection.immutable.List.foreach(List.scala:392)
    at scala.App.main(App.scala:80)
    at scala.App.main$(App.scala:78)
    at io.gatling.compiler.ZincCompiler$.main(ZincCompiler.scala:39)
    at io.gatling.compiler.ZincCompiler.main(ZincCompiler.scala)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
    at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)

Мой отредактированный пом. xml:

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

    <modelVersion>4.0.0</modelVersion>

    <groupId>***</groupId>
    <artifactId>****</artifactId>
    <version>1.0</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <gatling.version>3.3.1</gatling.version>
        <gatling-plugin.version>3.0.5</gatling-plugin.version>
        <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
        <!-- <scala-maven-plugin.version>4.3.1</scala-maven-plugin.version> -->
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.gatling.highcharts</groupId>
            <artifactId>gatling-charts-highcharts</artifactId>
            <version>${gatling.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testSourceDirectory>simulations</testSourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>bash</executable>
                    <arguments>
                        <argument>run.sh</argument>
                        <argument>${env.NS}</argument> <!-- will be empty if running with services -->
                    </arguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>${gatling-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!-- the name of the single Simulation class to run -->
                    <simulationClass>${env.SIMULATION}</simulationClass>
                    <runMultipleSimulations>false</runMultipleSimulations>                   <!-- if the plugin should run multiple simulations sequentially -->
                    <includes>                                                               <!-- include filters, see dedicated section below -->
                        <include></include>
                    </includes>
                    <excludes>                                                               <!-- exclude filters, see dedicated section below -->
                        <exclude></exclude>
                    </excludes>
                    <reportsOnly></reportsOnly>                                              <!-- to only trigger generating HTML reports from the log file contained in folder parameter -->
                    <runDescription>****</runDescription>             <!-- short text that will be displayed in the HTML reports -->
                    <failOnError>true</failOnError>                                          <!-- report failure in case of assertion failure, typically to fail CI pipeline -->
                    <continueOnAssertionFailure>false</continueOnAssertionFailure>           <!-- keep on executing multiple simulations even if one fails -->
                    <useOldJenkinsJUnitSupport>true</useOldJenkinsJUnitSupport>             <!-- report results to Jenkins JUnit support (workaround until we manage to get Gatling support into Jenkins) -->
                    <!-- pass extra parameters to the Gatling JVM -->
                    <jvmArgs>
                        <jvmArg>-DIAM=${env.IAM}</jvmArg>
                        <jvmArg>-DStarterkitsDir=${env.STARTERKITS_DIR}</jvmArg>
                        <jvmArg>-DServicesDir=${env.SERVICES_DIR}</jvmArg>
                        <jvmArg>-DGROUP=${env.RESOURCE_GROUP}</jvmArg>
                        <jvmArg>-DGORG=${env.ORG_GUID}</jvmArg>
                        <jvmArg>-DSPACE=${env.SPACE_GUID}</jvmArg>
                        <jvmArg>-DURL=${env.URL}</jvmArg>
                        <jvmArg>-DUsers=${env.USERS}</jvmArg>
                        <jvmArg>-DDuration=${env.DURATION}</jvmArg>
                    </jvmArgs>
                    <overrideJvmArgs>false</overrideJvmArgs>                                 <!-- if above option should override the defaults instead of replacing them -->
                    <propagateSystemProperties>true</propagateSystemProperties>              <!-- if System properties from the maven JVM should be propagated to the Gatling forked one -->
                    <!-- pass extra parameters to the Compiler JVM -->
                    <compilerJvmArgs>
                    </compilerJvmArgs>
                    <!-- if above option should override the defaults instead of replacing them -->
                    <overrideCompilerJvmArgs>false</overrideCompilerJvmArgs>    
                    <!-- extra options to be passed to scalac -->             
                    <!-- <extraScalacOptions>                                                     
                        <extraScalacOption></extraScalacOption>
                    </extraScalacOptions> -->
                    <disableCompiler>false</disableCompiler>                                 <!-- if compiler should be disabled, typically because another plugin has already compiled sources -->
                    <simulationsFolder>${project.basedir}/simulations</simulationsFolder> <!-- where the simulations to be compiled are located -->
                    <resourcesFolder>${project.basedir}</resourcesFolder> <!-- where the test resources are located -->
                    <resultsFolder>${project.basedir}/target/gatling</resultsFolder>         <!-- where the simulation log and the HTML reports will be generated -->
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Ответы [ 2 ]

0 голосов
/ 29 апреля 2020

В gatling-maven-plugin нет ничего плохого.

Как я уже говорил в проблеме, которую вы открыли на нашем трекере ошибок, скорее всего, в вашем локальном репозитории maven есть несколько поврежденных jar-файлов.

Maven иногда портится при загрузке jar-файлов и все еще устанавливает поврежденные файлы в локальный репозиторий. ClassLoader не может открыть jar-файлы (jar-файлы - это просто zip-файлы) и молча игнорирует их, вызывая NoClassDefFoundErrors во время выполнения.

0 голосов
/ 29 апреля 2020

Похоже, что компиляция gatling-maven-plugin не работает или что-то еще происходит. Я перешел на использование scala-maven-plugin, и это успешно компилирует мои классы симуляции.

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>${scala-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <jvmArgs>
                                <jvmArg>-Xss100M</jvmArg>
                            </jvmArgs>
                            <args>
                                <arg>-target:jvm-1.8</arg>
                                <arg>-deprecation</arg>
                                <arg>-feature</arg>
                                <arg>-unchecked</arg>
                                <arg>-language:implicitConversions</arg>
                                <arg>-language:postfixOps</arg>
                            </args>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
...