'Maven error: Unable to load cache item not working on vps but works locally

So I have been trying to compile my maven project on a VPS and made sure that all the versions of maven and jdk are the same as on my system. I even use the same system yet when I compile it on the VPS I get the 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

the output of mvn -v is:

Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 17.0.1, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-17-oracle
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-97-generic", arch: "amd64", family: "unix"

output of java -version is:

java version "17.0.1" 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source