I can't execute the command
mvn clean install
[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
and other similar commands, since the project is in java 17.
I was trying to install the latest version of maven:
java --version
openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 17.0.3+7-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
which java
/usr/bin/java
mkdir -p tmp
TMP_MAVEN_VERSION=3.8.5
wget -P ~/tmp/ https://dlcdn.apache.org/maven/maven-3/3.8.5/binaries/apache-maven-$TMP_MAVEN_VERSION-bin.tar.gz
sudo tar xf ~/tmp/apache-maven-*.tar.gz -C /opt
sudo rm ~/tmp/apache-maven-*-bin.tar.gz
sudo ln -s /opt/apache-maven-$TMP_MAVEN_VERSION /opt/maven
sudo touch /etc/profile.d/maven.sh
Change owner
sudo chown user /etc/profile.d/maven.sh
Add to file
export JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=$M2_HOME/bin:$PATH
sudo chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh
mvn -v
An error appears
/opt/maven/bin/mvn: 1: uname: not found
/opt/maven/bin/mvn: 1: dirname: not found
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
I close the terminal and open it again
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 17.0.3, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.13.0-44-generic", arch: "amd64", family: "unix"
I need the latest version package in the system.
Maybe who knows how to fix this problem?
You need to do this:
to correct that (/etc/profile.d/maven.sh):
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=$M2_HOME/bin:$PATH
and to perform
source /etc/profile.d/maven.sh
Related
I installed OpenJDK 11 and Maven 3.8.1 on Red Hat Enterprise Linux release 8.3 as follows:
yum install java-11-openjdk
cd /opt
wget https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
mv apache-maven-3.8.1 /opt/maven
Then I created the maven.sh script to declare JAVA_HOME and M2_HOME environment variables as follows:
vi /etc/profile.d/maven.sh
# added the following content:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
Reloade the shell with source /etc/profile.d/maven.sh.
When checking the installed Maven version, it is not displayed, just the Java's one:
mvn -v
Maven home: /opt/maven
Java version: 11.0.10, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.10.0.9-4.el8_3.x86_64
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "4.18.0-240.15.1.el8_3.x86_64", arch: "amd64", family: "unix"
I hoped to see something like:
Apache Maven 3.8.1 (cecedd343002696d0abb50b32b541b8a6ba2883f)
...
What am I missing? Or everything is correct?
I don't see anything wrong here. I have tried almost the same steps and it worked for me.
Adding those steps below
sudo yum install java-11-openjdk
sudo wget https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
sudo tar xvf apache-maven-3.8.1-bin.tar.gz
sudo ln -s apache-maven-3.8.1 maven
sudo vi /etc/profile.d/maven.sh
added the below
export JAVA_HOME={provide the path, where your jdk is}
export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
source /etc/profile.d/maven.sh
mvn -version
screenshot of maven version
Hopefully, this will work for you!
I installed maven with sudo apt install maven
Then, from this repo ran mvn clean install.
I got the following error
[ERROR] org.eclipse.xtext.maven.plugin.XtextGeneratorIT Time elapsed: 4.246 s <<< FAILURE!
java.lang.AssertionError:
Maven home not found. Tried to call 'mvn'.
Consider to set the envVar 'M2_HOME' or System property 'maven.home'.
Current settings are: maven.home=null M2_HOME=null
What should my M2_HOME be??? I typed mvn --version to get a clue:
$ mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_IL, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-109-generic", arch: "amd64", family: "unix"
But I'm not sure what to do now. Any help is appreciated, thanks!
M2_HOME is a home of Maven. It should be the root directory of your maven installation/binaries. It is used by script mvn (correspondingly mvn.bat on Windows).
At execution of any arbitrary mvn command I get following warnings at the beginning of the logs:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Unfortunately, these warnings sometimes lead to errors at runtime and break my maven command execution. Does anyone know how to address this and get rid of these warnings?
My maven version:
Apache Maven 3.5.2
Maven home: /usr/share/maven
Java version: 11.0.2, vendor: Azul Systems, Inc.
Java home: /usr/lib/jvm/zulu-11-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-47-generic", arch: "amd64", family: "unix"
My best guess: your guice version is not compatible with Java 11.
I am using Debian and the commands below removed this warning for me.
I am also using OpenJDK 11.
# Download maven 3.6.3
wget https://www.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp
# Untar downloaded file to /opt
sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
# Install the alternative version for the mvn in your system
sudo update-alternatives --install /usr/bin/mvn mvn /opt/apache-maven-3.6.3/bin/mvn 363
# Check if your configuration is ok. You may use your current or the 3.6.3 whenever you wish, running the command below.
sudo update-alternatives --config mvn
Running the final command, you should select the maven version 3.6.3.
After that the warning will be removed.
As JF Meier mentioned here, my guice version was incompatible with Java 11. A reinstallation of maven with the sdkman resolved this issue for me.
If you are using a custom version of Maven or maybe Ubuntu WSL, then, remove Maven, download it from official site and install it.
Example if you have WSL, assuming you have a /c/tools directory:
$ sudo apt-get remove maven
$ cd /c/tools/
$ tar xzvf /c/Users/<USER-NAME>/Downloads/apache-maven-3.6.3-bin.tar.gz
$ echo "PATH=/c/tools/apache-maven-3.6.3/bin:$PATH" >> ~/.profile
$ source ~/.profile
$ mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /c/tools/apache-maven-3.6.3
Java version: 11.0.8, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-18362-microsoft", arch: "amd64", family: "unix"
I was having the problem even with a recent Maven distribution. It seems that the packaged Mint version reuses the package libguice-java instead of using a guice-4.2.1-no_aop.jar.
So installing the binaries from the Maven site fixed the issue.
I just experienced the issue recently and in my case I was using older version of Spring
So I changed from this
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
to this
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
and it worked for my case
Guice has just released a new version, the v5.0.1.
Upgrading to this one should fix the problem without having to downgrade your Java version from 11.
There is an issue of this exact same problem in guice's github.
I am very new to Spark and attempting a first time install. I have downloaded homebrew and installed Maven with it.
I have run the following to ensure the install was done correctly:
Command: maven - v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.3", arch: "x86_64", family: "mac"
However, when I try to build spark using the following command:
./build/mvn -Pyarn -Phadoop-2.4 -Dhadoop.version=2.4.0 -DskipTests clean package
I get this error:
-bash: ./build/mvn: No such file or directory
UPDATE:
I went on to follow instructions on instaling Spark with Homebrew from here:
• https://medium.com/#josemarcialportilla/installing-scala-and-apache-spark-on-mac-os-837ae57d283f#.ru5hi42v3
This worked fine untill I restarted the terminal. When I execute
spark-shell
I get :
/usr/local/Cellar/apache-spark/2.1.0/libexec/bin/spark-shell: line 57: /usr/local/Cellar/apache-spark/2.0.1/libexec/bin/spark-submit: No such file or directory
Would appreciate any pointers in resolving this.
UPDATE
I have updated my .bash_profile to this.
Still getting the same error. However when I access the files directly by going to the folder via terminal, I can open it.
If the version of spark you installed is not 2.1.0, then you have to modify the line export SPARK_HOME= .... to correspond to version of spark you have.
I can't seem to get gradle to install on work on opensuse 13.2.
Installed by:
sudo unzip -oq gradle-2.2.1-all.zip -d /opt/gradle
sudo ln -sfn gradle-2.2.1 /opt/gradle/latest
export GRADLE_HOME=/opt/gradle/latest
export PATH=$GRADLE_HOME/bin:$PATH
running gradle:
$gradle -v
java.lang.NoClassDefFoundError: org.gradle.util.CollectionUtils
at java.lang.Class.initializeClass(libgcj.so.14)
at org.gradle.internal.classpath.DefaultClassPath.<init>(DefaultClassPath.java:37)
at org.gradle.api.internal.classpath.EffectiveClassPath.<init>(EffectiveClassPath.java:32)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.<init>(DefaultModuleRegistry.java:61)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.<init>(DefaultModuleRegistry.java:55)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:44)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/opt/gradle/gradle-2.2.1/lib/gradle-launcher-2.2.1.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at java.lang.Class.initializeClass(libgcj.so.14)
...7 more
Have you tried adding the symlink in /usr/bin?
Like this:
sudo ln -s /opt/gradle/latest/bin/gradle /usr/bin/gradle
It worked for me in openSuse 13.2
Make sure gradle is using Java 1.8
> $JAVA_HOME/bin/java -version
Should return
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (IcedTea 3.8.0) (build 1.8.0_171-b11 suse-24.1-x86_64)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
My box had $JAVA_HOME linked to Java 1.5