Reputation: 1357
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"
Upvotes: 34
Views: 37732
Reputation: 197
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>
</parent>
to this
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
</parent>
and it worked for my case
Upvotes: 1
Reputation: 19944
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://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/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.
Upvotes: 26
Reputation: 5
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.
Upvotes: 0
Reputation: 11655
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.
Upvotes: 3
Reputation: 1059
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"
Upvotes: 9
Reputation: 1357
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.
Upvotes: 11
Reputation: 35795
My best guess: your guice
version is not compatible with Java 11.
Upvotes: 31