mvn dependency:tree hangs trying to read repository - maven

$ mvn --version
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /home/redacted/.sdkman/candidates/maven/current
Java version: 17.0.1, vendor: Azul Systems, Inc., runtime: /home/redacted/.sdkman/candidates/java/17.0.1.fx-zulu
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-91-generic", arch: "amd64", family: "unix"
Running the following command never finishes and it appears to be hung.
mvn -X dependency:tree -Dverbose
The last lines of the debug log report:
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://repository.tesla.io:8081/nexus/content/repositories/snapshots/
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://repository.tesla.io:8081/nexus/content/repositories/snapshots/
I'm curious why running a dependency tree command is causing maven to try to hit the tesla.io repository on port 8081.
Is there some way to tell dependency:tree to skip this repository (or to configure some timeout and skip all repositories that are unreachable within some specified timeout limit)?
How can I trace the reason why dependency:tree is trying to read from the tesla repository?

As mentioned in the comment above by SteveGreenslade, and per the maven-dependency-plugin documentation:
verbose:
Deprecated. in 2.5
Whether to include omitted nodes in the serialized dependency tree.
Type: boolean
Since: 2.0-alpha-6
Required: No User Property: verbose
Default: false
Removing the -D verbose flag after upgrading the plugin above version 2.5 fixed the problem for me.

Related

Why would apache-maven-3.5.3-bin work and apache-maven-3.8.4-bin wouldn't work

I was testing the move from a Jenkins docker image to another using Thinbacvkup and restore the backup and restore went well and of course it didn't bring maven with it (No problem there) I went online and got the latest apache maven bin file (apache-maven-3.8.4-bin), extracted and set up the global tool configuration, export M2_HOME ...ETC. BUT for some reason, it didn't work giving me the same message
#tmp/durable-e665ee46/script.sh: 1: mvn: not found
searched and searched nothing worked, so I went to the original docker and got the same maven from there (apache-maven-3.5.3-bin)edited the configs and all, and it worked but now I wanted to know why did this work and that won't is there something with my project, build or what?
Not using a Docker image, but had no problem on a clean install, no plugins,
Global Tool Configuration ( /configureTools/ ), add maven configuration:
Create job with Invoke top-level maven step, choose same maven version:
If a pipeline job, then the reference would be tools:
tools {
maven 'maven-3.8.4'
}
or withMaven:
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: 'maven-3.8.4',
Works fine. I did not set M2_HOME or add to PATH; Tool configuration takes care of that.
Started by user admin
Running as SYSTEM
Building in workspace C:\Users\jenkins\.jenkins.2.322.new\workspace\M-Foo
Unpacking https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip to C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4 on Jenkins
[M-Foo] $ cmd.exe /C "C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4\bin\mvn.cmd -version && exit %%ERRORLEVEL%%"
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Tools\Java\jdk8\jre
Default locale: en_CA, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Finished: SUCCESS
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\jenkins.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4
Note: you must have proxy set up properly for the "Install from Apache" to populate for "Install automatically".
If you un-tick "Install automatically", then you must input the MAVEN_HOME (which should really be labelled M2_HOME) and then choose that.
Started by user admin
Running as SYSTEM
Building in workspace C:\Users\jenkins\.jenkins.2.322.new\workspace\M-Foo
[M-Foo] $ cmd.exe /C "C:\Tools\apache-maven\apache-maven-3.8.1\bin\mvn.cmd -version && exit %%ERRORLEVEL%%"
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Tools\apache-maven\apache-maven-3.8.1\bin\..
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Tools\Java\jdk8\jre
Default locale: en_CA, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Finished: SUCCESS
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Tools\apache-maven\apache-maven-3.8.1\bin..

Maven slowdown taking 3,4 minutes after "[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 ..."

My Maven system suddenly slows down, when I run with "-X" option, got this
[me#centos7 component]$ mvn -X
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_74, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_74/jre
Default locale: en_AU, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /usr/share/maven/conf/settings.xml
[DEBUG] Reading user settings from /home/<me>/.m2/settings.xml
[DEBUG] Using local repository at /home/<me>/.m2/repository
**[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /home/<me>/.m2/repository**
...
It stops for about 3,4 minutes after the line:
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /home/<myuser>/.m2/repository
Does anyone know what is going on ? Or how to investigate further why it is suddenly slowing down ?
Cheers, Tuan.

Maven reading settings.xml from wrong place

I am new to Maven and Ubuntu. I am having trouble building maven projects. When I run the mvn clean -X command I can see the below DEBUG logs.
[DEBUG] Reading global settings from /space/user/programs/apache-maven-3.5.3/conf/settings.xml
[DEBUG] Reading user settings from ?/.m2/settings.xml
[DEBUG] Reading global toolchains from /space/user/programs/apache-maven-3.5.3/conf/toolchains.xml
[DEBUG] Reading user toolchains from ?/.m2/toolchains.xml
[DEBUG] Using local repository at /space/user/git/receiver/?/.m2/repository
I have following settings in .bashrc file
export JAVA_HOME=/space/user/programs/jdk1.8.0_162
export M2_HOME=/space/user/programs/apache-maven-3.5.3
export MAVEN_HOME=/space/user/programs/apache-maven-3.5.3
And I have settings.xml file in /home/user/.m2 folder
Why maven is not picking /home/user/.m2/settings.xml? What is it that I am missing here please? If you need any further information please let me know and I will update the question.
I am using Ubuntu 16.04.
UPDATE:
Output of mvn --version command
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T19:49:05Z)
Maven home: /space/user/programs/apache-maven-3.5.3
Java version: 1.8.0_162, vendor: Oracle Corporation
Java home: /space/user/programs/jdk1.8.0_162/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "4.13.0-37-generic", arch: "i386", family: "unix"
UPDATE:
Overriding settings on command line like this mvn --settings /home/user/.m2/settings.xml clean -X works fine. But this is not the solution I want.
The solution was to use 64-bit JDK on a 64-bit system. I somehow copied 32-bit JDK, and this was the problem. It worked as expected with a 64-bit runtime.
This question helped me solve the issue - Java: System.getProperty("user.home") returns "?"
Note: your linux machine might have both a 32-bit and a 64-bit version of the JVM installed. Even Java 11. #Newbee is correct that this can cause weird maven behavior that they described. Check your alternatives to see which one is being pointed at (for CentOS / RHEL machines):
ls -l /etc/alternatives/java_sdk_11
sudo alternatives --display java_sdk_11
sudo alternatives --config java_sdk_11

How exactly mvn -U works?

I want to know what exactly Maven do in the -U phase.
The argument ordering forced check for updates on remote repositories and if needed, updating the local maven repository with the updated dependencies used in our project.
As described:
-U --update-snapshots Forces a check for updated releases and snapshots on remote repositories
But, how exactly is this done? Is maven first of all downloading all the remote repositories and locally decides that they need to get updated, or, deciding without downloading them first? Is there some corner cases that should be known?
My Maven version is:
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T16:51:42+03:00)
Maven home: /usr/local/Cellar/maven/3.2.2/libexec
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac"
It is done only for the artifacts or dependencies referenced by your project.
The last check timestamp is stored within local artifact metadata (in your local Maven repository), so Maven can apply different strategies how often to check for updates based on that. The default update interval for snapshots is "daily".
Also see updatePolicy for remote repositories in Maven's settings.xml.

Maven not working?

Initially I used maven with proxy and it was working fine. Now I don't need the proxy, so I edited the settings.xml to not use proxy. After that, Maven does not connect to the Internet to download repos. I tried reinstalling, but still getting the same problem. I even tried IDEs like eclipse and IDEA but the problem was still there. How do I resolve this?
mvn --version
Apache Maven 2.2.1 (rdebian-8)
Java version: 1.6.0_24
Java home: /usr/lib/jvm/java-6-openjdk-i386/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux" version: "3.2.0-31-generic-pae" arch: "i386" Family: "unix"
mvn archetype:generate -DgroupId=org.sonatype.mavenbook.simple -DartifactId=simple -DpackageName=org.sonatype.mavenbook -Dversion=1.0-SNAPSHOT
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
Nothings happens after this.
All things considered, my initial thought is this is a connection issue since it fails to work after removing the proxy settings. Are you able to ping or curl the repository being scanned?

Resources