OS Linux - Ubuntu 20.04.2 LTS When compiling a project, Maven throws an error

[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

java -version

openjdk version "17" 2021-09-14 LTS
OpenJDK Runtime Environment (build 17+35-LTS)
OpenJDK 64-Bit Server VM (build 17+35-LTS, mixed mode, sharing)

mvn -version

Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 17, vendor: BellSoft, runtime: /usr/lib/jvm/bellsoft-java17-amd64
Default locale: ru_RU, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-37-generic", arch: "amd64", family: "unix"

java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'

java.home = /usr/lib/jvm/bellsoft-java17-amd64
  • There are many Linuxes. Which distro and version are you running? 🤔
    – matigo
    Oct 7, 2021 at 5:42

4 Answers 4


I faced the same issue. Sadly I just could update to 3.6.3 via the package manager so I installed it manually. Steps to install on ubuntu below:

Maven 3.3+ requires JDK 1.7 or above to be installed.

Download Apache Maven. I installed 3.8.6, you can check for the newest version here: https://maven.apache.org/download.cgi

We save the archive to /tmp

$ wget https://apache.org/dist/maven/maven-3/$TMP_MAVEN_VERSION/binaries/apache-maven-$TMP_MAVEN_VERSION-bin.tar.gz -P /tmp

Then unzip it to /opt and remove the archive

$ sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
$ sudo rm /tmp/apache-maven-*-bin.tar.gz

Next we create a sym-link

$ sudo ln -s /opt/apache-maven-$TMP_MAVEN_VERSION /opt/maven

Lastly we set up the env

$ sudo echo "export JAVA_HOME=/usr/lib/jvm/default-java
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}" >> /etc/profile.d/maven.sh

To use it without restarting we make it executable and run in

$ sudo chmod +x /etc/profile.d/maven.sh
$ source /etc/profile.d/maven.sh

Now you can verify that it is properly installed

$ mvn -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /opt/maven
Java version: 11.0.13, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-1022-aws", arch: "amd64", family: "unix"

derived by


Same issue i also faced.And i got the solution. Update latest maven version which is 3.8.3. With latest maven it is working.

mvn -v
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /opt/maven
Java version: 17, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "5.10.0-1051-oem", arch: "amd64", family: "unix"

I met the same mistake as you. my os version is ubuntu 20.04 LTS .

the reason is maven version(3.6.3) is old.

download lastest bin version (apache-maven-3.8.6-bin.zip) from https://maven.apache.org

i decompress files to /data/app/maven/3.8.6/apache-maven-3.8.6/bin

using command like this export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/ && /data/app/maven/3.8.6/apache-maven-3.8.6/bin/mvn

it works well on my machine


As of 2021/10/25, maven is not supporting Java 17.

Create vi ~/.mavenrc file and give any version lower than 17.

export JAVA_HOME=/usr/lib/jvm/java-16-openjdk-amd64/

  • it didn't work here...
    – Digao
    Dec 9, 2021 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.