测试打破jenkins但在本地运行

时间:2022-09-13 15:35:15

we are having such a weird error. Our Tests are running in the local machines (windows) but not running on jenkins (linux).

我们有这么奇怪的错误。我们的测试在本地机器(windows)中运行,但不在jenkins(linux)上运行。

We get a

我们得到一个

Caused by: java.lang.RuntimeException: There was an error in the forked process
java.lang.NoClassDefFoundError: 

I'm being looking for solution and got this info on bugzilla or archive.

我正在寻找解决方案,并在bugzilla或存档上获取此信息。

Has anybody an idea about this issue and how to solve it?

有没有人对这个问题有所了解以及如何解决这个问题?

Thanks

UPDATE

maven-surefire-plugin is also defined in the parent pom.xml for using with cobertura. The Tests are running twice but the second time the tests fails as described above.

maven-surefire-plugin也在父pom.xml中定义,用于与cobertura一起使用。测试运行两次,但第二次测试失败,如上所述。

I'm defining 2 profiles that are using the surefire-plugin and a surefire plugin definition in the section.

我正在定义两个配置文件,它们使用了surefire-plugin和一个surefire插件定义。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
            <configuration>
                <useSystemClassLoader>false</useSystemClassLoader>
                <excludes>
                    <exclude>**/*IntegrationTest.java</exclude>
                    <exclude>**/*SoapUiTest.java</exclude>
                </excludes>
                <excludes>
                    <!--exclude>**/*.java</exclude -->
                </excludes>
                <additionalClasspathElements>
                   <additionalClasspathElement>${basedir}/src/main/java</additionalClasspathElement>
                </additionalClasspathElements>
            </configuration>
        </plugin>
    </plugins>
</build>
<profiles>
    <profile>
        <id>soapUi</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                    <configuration>
                        <excludes>
                            <exclude>**/*EntityTest.java</exclude>
                        </excludes>
                        <includes>
                            <include>**/*SoapUiTest.java</include>
                        </includes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
       </profile>
        <profile>
            <id>integration</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven-surefire-plugin.version}</version>
                       <configuration>
                           <excludes>
                               <exclude>**/*EntityTest.java</exclude>
                           </excludes>
                           <includes>
                            <include>**/*IntegrationTest.java</include>
                           </includes>
                       </configuration>
                   </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

What I'm doing wrong?

我做错了什么?

2 个解决方案

#1


0  

I remember having similar issue. It might be related to ulimit - number of allowed opened files. ClassLoader needs to open file for loading. Since class is not loaded/available NoClassDefFoundError is thrown on method call. Check how many files can be opened:

我记得有类似的问题。它可能与ulimit有关 - 允许打开的文件数。 ClassLoader需要打开文件进行加载。由于未加载/可用类,因此在方法调用时抛出NoClassDefFoundError。检查可以打开的文件数:

ulimit -a

To increase number of opened files:

要增加打开的文件数:

ulimit -n NEW_NUMBER

In order to change it permanently follow instructions from this link

要永久更改,请按照此链接中的说明进行操作

Follow the steps:

按照步骤:

vi /etc/security/limits.conf and add below the mentioned

vi /etc/security/limits.conf并在下面提到

  • soft nofile 65535
  • soft nofile 65535

  • hard nofile 65535
  • hard nofile 65535

#2


0  

It was an ussue with cobertura itself (-Dcobertura.test=true). Activating it resolved the Problem.

这是cobertura本身的一个问题(-Dcobertura.test = true)。激活它解决了问题。

#1


0  

I remember having similar issue. It might be related to ulimit - number of allowed opened files. ClassLoader needs to open file for loading. Since class is not loaded/available NoClassDefFoundError is thrown on method call. Check how many files can be opened:

我记得有类似的问题。它可能与ulimit有关 - 允许打开的文件数。 ClassLoader需要打开文件进行加载。由于未加载/可用类,因此在方法调用时抛出NoClassDefFoundError。检查可以打开的文件数:

ulimit -a

To increase number of opened files:

要增加打开的文件数:

ulimit -n NEW_NUMBER

In order to change it permanently follow instructions from this link

要永久更改,请按照此链接中的说明进行操作

Follow the steps:

按照步骤:

vi /etc/security/limits.conf and add below the mentioned

vi /etc/security/limits.conf并在下面提到

  • soft nofile 65535
  • soft nofile 65535

  • hard nofile 65535
  • hard nofile 65535

#2


0  

It was an ussue with cobertura itself (-Dcobertura.test=true). Activating it resolved the Problem.

这是cobertura本身的一个问题(-Dcobertura.test = true)。激活它解决了问题。