MVN Package Build Failure - java

I am trying to package a java project using maven. I've done it before on my old computer, but I can't seem to make it work on my new computer.
Here is the error:
`
(env)kyle#thinkpad ~/Code/simplefilehosting $ mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_95, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-38-generic", arch: "amd64", family: "unix"
(env)kyle#thinkpad ~/Code/simplefilehosting $ java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
(env)kyle#thinkpad ~/Code/simplefilehosting $ javac -version
javac 1.7.0_95
(env)kyle#thinkpad ~/Code/simplefilehosting $
Here is my version information for java, javac and mvn:
(env)kyle#thinkpad ~/Code/simplefilehosting $ mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_95, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-38-generic", arch: "amd64", family: "unix"
(env)kyle#thinkpad ~/Code/simplefilehosting $ java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
(env)kyle#thinkpad ~/Code/simplefilehosting $ javac -version
javac 1.7.0_95
(env)kyle#thinkpad ~/Code/simplefilehosting $
I tried looking at it online and add a plugin but then my mvn never realized the plugins tag or anything else. And I haven't changed the pom.xml from the last time I was able to package it.

Without the actual error message to diagnose (I think you intended to include it but didn't)...but a few things:
-check your M2_HOME and JAVA_HOME variables and make sure they are correct
-make sure settings.xml is in your ~/.m2 or $M2_HOME/config directories
-on your old machine, delete your entire ~/.m2/repository directory and see if it builds, if you upgraded Maven along the way there might be something you already have that Maven3 can't for some reason download
-consider upgrading, 3.0.5 was an intermediate version that was between the old Maven2 and Maven3 artifact resolution, some major differences, some completely different behavior, who knows what you have.

Related

How to fix IntelliJ Idea stuck on "Preparing WSL build environment..."?

I am using Ubuntu 22.04 with windows WSL, and have installed JDK 19.01 and Maven inside this, and have imported a file from the WSL into IntelliJ Idea to work on, however once I run a class, IntelliJ "builds" for upwards of half an hour, hanging on the messages of "Executing pre-compile tasks..." and "Preparing WSL build environment...". Obviously this is a pain and I need to know how to fix it.
I've tried to reinstall my JDK in Ubuntu and set the JAVA_HOME variable, which I've checked and have no issues with. I've tried to reinstall IntelliJ, and disabled my firewall/made exceptions, and I've changed the SDK being used inside IntelliJ, all to no success.
Here are logs from inside the Ubuntu terminal showing my JDK and Maven installations:
user#user  \~  mvn -v
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 19.0.1, vendor: Private Build, runtime: /usr/lib/jvm/java-19-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.10.16.3-microsoft-standard-wsl2", arch: "amd64", family: "unix"
user#user  \~  javac -version
javac 19.0.1
user#user  \~  java -version
openjdk version "19.0.1" 2022-10-18
OpenJDK Runtime Environment (build 19.0.1+10-Ubuntu-1ubuntu122.04)
OpenJDK 64-Bit Server VM (build 19.0.1+10-Ubuntu-1ubuntu122.04, mixed mode, sharing)
user#user  \~  echo $JAVA_HOME
/usr/lib/jvm/java-19-openjdk-amd64
user#user  \~  which java
/usr/bin/java
user#user  \~  which javac
/usr/bin/javac
Disable the real-time antivirus monitoring. It's a known issue.
Remove fsnotifier.exe and idea64.exe in windows defender or follow the directions in this post:
https://youtrack.jetbrains.com/issue/IDEA-293604/IntelliJ-is-hanging-during-build-process-and-indexing-process-when-working-on-the-WSL-projects.#focus=Comments-27-6180537.0-0

Reconcile java versions between maven and java

When I'm calling mvn --version I get the following :
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /usr/local/Cellar/maven/3.8.2/libexec
Java version: 16.0.2, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: US-ASCII
OS name: "mac os x", version: "11.4", arch: "x86_64", family: "mac"
So I take the version 16 is used
But when I'm calling java -version :
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
Here I have java11.
I found out that the mvn command (found using which mvn) is actually a bash script in which the JAVA_HOME variable is defined, so I do get how I'm landing into /usr/local/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home when running maven.
But what is extremely confusing is the behaviour of java -version. java refers to an executable /usr/bin/java that is just lying there. And if I set the JAVA_HOME :
JAVA_HOME=/usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home
Then java -version returns :
openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment Homebrew (build 16.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 16.0.2+0, mixed mode, sharing)
So it looks like the /usr/bin/java executable reads this variable and calls the corresponding "real" java exec...
But then, my paramount question is : when the JAVA_HOME variable isn't defined, how the heck is this /usr/bin/java executable figuring where is the openjdk in version 11 ?
The short answer is on macos /usr/bin/java is the same executable as /usr/libexec/java_home. See the manual page for java_home(1) which references a "default order."

Not able to switch java home properly in mac

I have two versions of Java in my mac and I am trying to switch from 1.8 to 1.7 for compiling one of my project which has 1.7 specific contents. Though I ran the following commands in the terminal:
$ alias setJdk1.7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
$ setJdk1.7
With that, I can see the proper version in java -version and mvn -version.
$ java -version
java version "1.7.0_181"
Java(TM) SE Runtime Environment (build 1.7.0_181-b09)
Java HotSpot(TM) 64-Bit Server VM (build 24.181-b09, mixed mode)
$ mvn -version
Apache Maven 3.0.5 (...)
Maven home: *mvn path*
Java version: 1.7.0_181, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_181.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.5", arch: "x86_64", family: "mac"
However, the /usr/libexec/java_home still seems to be pointing to the 1.8 java only.
$ echo $(/usr/libexec/java_home)
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
I am very new to mac and not really sure how I can toggle between versions. This is not allowing to successfully compile my project.
Maybe try using a function instead and setting up your command as follows:
setJdk1.7() {
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
export PATH=$JAVA_HOME/bin:$PATH
}
Your command likely doesn't work because $JAVA_HOME is never added to your $PATH.

Environment variables returning blank even though Maven build is happening fine

I'm using Maven as a build tool for Scala code. I'm able to build the Scala objects fine using maven. However when I echo $M2_HOME ,$M2,$JAVA_HOME, everything is returning blank. While this is a sign that these environment variables are not set properly, they are not causing any issues, which to me sounded a bit surprising. Can you please let me know what I'm missing here. I'm running Ubuntu 15.04 and included the below output if needed.
~$java -version
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
~$mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_45-internal, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-58-generic", arch: "amd64",family: "unix"
This is the first time I'm using Java, Maven and Scala so kindly excuse my ignorance.

Cannot access DisposableBean and cannot access InitialzingBean

I'm trying to compile the oVirt open source project on fedora core 21,
java -version
openjdk version "1.8.0_20"
OpenJDK Runtime Environment (build 1.8.0_20-b26)
OpenJDK 64-Bit Server VM (build 25.20-b23, mixed mode)
I am getting the following errors:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project builtin: Compilation failure: Compilation failure:
[ERROR] /home/jenkins/workspace/ovirt-engine_master_find-bugs_merged_nomvn/ovirt-engine/backend/manager/modules/builtin-extensions/src/main/java/org/ovirt/engine/extensions/aaa/builtin/kerberosldap/utils/ipa/SimpleAuthenticationCheck.java:[61,25] error: cannot access InitializingBean
[ERROR] /home/jenkins/workspace/ovirt-engine_master_find-bugs_merged_nomvn/ovirt-engine/backend/manager/modules/builtin-extensions/src/main/java/org/ovirt/engine/extensions/aaa/builtin/kerberosldap/LDAPTemplateWrapper.java:[145,31] error: cannot access DisposableBean
mvn -version shows :
mvn -version
Apache Maven 3.2.2 (NON-CANONICAL_2014-06-19T11:19:24_mockbuild; 2014-06-19T11:19:24+00:00)
On fedora core18 it works -
Apache Maven 3.0.4 (rNON-CANONICAL_2013-04-08_07-49_mockbuild; 2013-04-08 10:49:23+0300)
Maven home: /usr/share/maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.9.11-200.fc18.x86_64", arch: "amd64", family: "unix"
The spring that is being used is aligned to 3.1.1.RELEASE from what I can see
In both the machines.
Can you give a hand? I know I'm using code that implements InitialzingBean and DisposableBean, but still - if same spring version, how come it does not compile
we had this problem and we had installed JDK 1.8. When we installed JDK 1.7 then this issue disappeared. Try it, maybe it is your case :)

Categories

Resources