0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

mvnコマンドをするとCould not initialize class com.google.inject.internal.cglib.core.$MethodWrapperエラーが出る

Last updated at Posted at 2023-05-26

はじめに

ローカルのJava環境でmvnコマンドを実行したところうまく行かなかったのでまとめていきます
ChatGPTにきいてもよくわからずで困っていました

問題

mvn testを実行すると以下のようなエラーが出ます

[ERROR] Error executing Maven.
[ERROR] java.lang.IllegalStateException: Unable to load cache item
[ERROR] Caused by: Unable to load cache item
[ERROR] Caused by: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapper

解決方法

mvnをapt getで入れるのではなく、最新版をtar.gzから入れるようにしました

$ sudo apt-get purge maven
$ wget https://dlcdn.apache.org/maven/maven-3/3.9.2/binaries/apache-maven-3.9.2-bin.tar.gz
$ sudo tar xzf apache-maven-3.9.2-bin.tar.gz -C /opt 
$ sudo ln -s /opt/apache-maven-3.9.2 /opt/maven 
$ sudo vi /etc/profile.d/maven.sh

以下を追記する

maven.sh
export JAVA_HOME=/usr/lib/jvm/default-java
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
$ source /etc/profile.d/maven.sh
$ mvn -version

Apache Maven 3.9.2 (c9616018c7a021c1c39be70fb2843d6f5f9b8a1c)
Maven home: /opt/maven
Java version: 11.0.19, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: ja_JP, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-72-generic", arch: "amd64", family: "unix"
$ rm -f apache-maven-3.9.2-bin.tar.gz 

おわりに

ChatGPTから解決方法が返ってくるかはわかりませんが、エラー分を記録しておくという使い方もできるのでとりあえず投げとくと良いですね

参考文献

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?