LoginSignup
13
6

More than 5 years have passed since last update.

Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter が発生した

Last updated at Posted at 2018-11-01

Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter が発生した

前提

  • Jenkins で Maven プロジェクトをビルド → テストしている

単体テスト実行時にエラーが発生した

特に何もした覚えがないが、以下のエラーが発生するようになってしまった。

Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter
The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

調査

ググると以下の情報を発見。

https://stackoverflow.com/questions/53010200/maven-surefire-could-not-find-forkedbooter-class?noredirect=1&lq=1
https://issues.apache.org/jira/browse/SUREFIRE-1588

maven-surefire-plugin の不具合みたい。
maven-surefire-plugin は、アプリケーションの単体テスト実行のライフサイクルを管理するためのプラグイン。

対応

今までは pom.xmlmaven-surefire-plugin の設定をしていなかった。
pom.xml に下記を追加することで解決。

pom.xml
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.1</version>
    <configuration>
        <useSystemClassLoader>false</useSystemClassLoader>
    </configuration>
</plugin>

useSystemClassLoader を false にする必要がある。

13
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
6