Why does mvn command take forever? - maven

$ mvn dependency:tree -Dincludes=com.fasterxml.jackson.core
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/jooq/jooq-codegen-maven/3.9.1/jooq-codegen-maven-3.9.1.pom
I am executing this command, but it takes forever and got stuck here. My network is all good and I tried the command at different time but ended with the same. What might be the problem?

I've seen all kinds of problems with this. No idea what your specific issue is but here's a few possibilities
Your traffic is going through some kind of stateful package inspection/firewall/antivirus/IDS/bluecoat/etc and it's interfering and/or silently dropping the connection
There's some issues validating the certificate
The server is offline, which happens from time to time but is unlikely
Your settings.xml file is redirectly elsewhere and that "elsewhere" location is misbehaving.
A few suggestions to work around the issue
try disabling https (i know) by using settings.xml to remap the apache repo from https to http.
try disabling any antivirus/firewall (temporarily) to try and isolate the problem.
check to make sure your hard drive is not full

To troubleshoot run mvn with --debug flat to see any issues to find if mvn is stuck on any command. Based on this, if you still need help, please update this question
mvn --debug ...

Related

Jenkins Travis-CI build fails in cli module (shade fails)

I am running a custom Jenkins 2.263.4 build on Travis-CI. We need a fix with relative pathes that never made it into the Jenkins core...well for us it is mandatory.
Based on release 2.263.4 I applied the fix in core/SecretRewriter.java and core/VirtualFile.java and also changed the version name to give it branding. This worked very well in the past releases. But the last update we did was one year ago.
Now I am running into the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.1:shade (default) on project cli: Error creating shaded jar: duplicate entry: META-INF/services/io.jenkins.cli.shaded.org.apache.sshd.common.io.IoServiceFactoryFactory -> [Help 1]
I am not able to understand it at all.
Travis-CI is here: https://travis-ci.com/github/DanielWeber/jenkins
GitHub: https://github.com/DanielWeber/jenkins
I was not able to find this exact problem from somewhere else. I tried a bit with the shade config to set
<minimizeJar>false</minimizeJar>
and similar small things, but didn't really help.
My change is so small, I don't really understand what's happening.
If nothing helps, I might consider doing changes step by step then, rather than just merging the releae to our for, but hope someone sees the problem.
The issue is that the build is being execute two times based on the mvn install followed by mvn package which is defined in travis.yml file. This causes the issue.

Build Error while building aperturejs

I am trying to build aperturejs with Readme.md instructions.
I cloned the repository and tried the command mvn clean install in the root directory of ApertureJs.
I got the following Build Error as in the screenshot,
I am using the latest version of Maven - 3.3.9
Thanks in advance.
By reading the error in your console, I could feel that you are not authorized to access the particular repository, which is shown in your console.
Copy the repository url and try it from a browser - hope you will not be able to access the repository, since you are not authorized.
Raise appropriate access and after getting access, then try mvn clean install.
Below is the Quick fix till the time you get the access:
Copy and Paste the respective jar/pom/folder from your colleague machine, in your .m2/repository/...
Run the mvn clean install with -o option so that it will look into your local repository for building your application
Thank you. The issue is solved. I posted this issue to Uncharted Software's Salt Repository and exactly like Clement Said, I was trying to access a repository that no more has access publicly. Therefore they gave a workaround.
It is available here -> https://github.com/unchartedsoftware/aperturejs/issues/22
Thanks a lot.

How to use maven or gradle on an unreliable network?

Naive use of the built-in settings sometimes results in hanging connections. It is likely some network issue outside of my control.
I would like to know how I can set a timeout and a retry for both downloading artifacts and publishing artifacts.
I have found a connection timeout and read timeout setting for HTTP wagon, but I have not found a retry option.
For publishing, I found a retry option, but no timeout setting.
http://maven.apache.org/guides/mini/guide-http-settings.html#Connection_Timeouts
https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
Edit what I want is the equivalent of curl's --max-time, --retry and --retry-delay options for maven and gradle downloads and publishes.
I tried to dig into this topic as well, but did not find much. Except one thing. Since Gradle 4.3 (thanks to PR) you can put to gradle.properties something like:
systemProp.org.gradle.internal.http.connectionTimeout=120000
systemProp.org.gradle.internal.http.socketTimeout=120000
Maybe once https://github.com/gradle/gradle/issues/4629 would be resolved, life will be much easier.
Gradle has built-in Maven compatability and it will create the .m2 or .gradle archive directories for you. To retry, all you need to do is just re-run your build over and over until all artifacts are complete.

Forcing authentication on Maven release

I have a problem getting Maven to release to a Nexus server. Seemingly, it refuses to use my provided username and password (but there might be other problems as well).
When I first type 'mvn release:perform', I get a'not authorized'-error. However, some files are created on the Nexus, namely a pom with checksums etc. When I try a second time (without changing anything), I get a different error: '400 bad request'
When I delete the files and try again, I get the first error once again.
I have run this with the -X flag to see if I can make any sense of what is happening, and I have discovered that the first time I run the command, maven omits my username and password provided in settings.xml:
[INFO] [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://nexus.example.com/content/repositories/releases
When I run it the second time, it includes my credentials:
[INFO] [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://nexus.example.com/content/repositories/releases/ as developers
Notice it says 'as developers'
Of course I don't know that the fact that it prints it differently actually means anything, but it seems that way.
When I allow redeploy for the releases repository in Nexus, I always get the first variant (not authorized).
If anyone can tell me how I might force Maven to use my credentials (if that is indeed what it is not doing) or on what else might be wrong, I would be very happy.
I have got it working now, by specifying in the maven release plugin that it only deploy, and not deploy and deploy site as is default.
mvn site:deploy fails with the error: Wagon protocol 'http' does not support directory copying.
Of course, my original error message did not refer very much to site at all.
Way to produce useful error messages, Maven!
I found a way to force preemptive authentication here: http://maven.apache.org/guides/mini/guide-http-settings.html (it didn't solve my problem, but it is an answer to the title.)

Running "mvn archetype:generate" stalls

When I try to run the command mvn archetype:generate it stalls when trying to download maven-assembly-plugin-2.2-beta-5.jar
No matter how many times I cancel the batch process or close cmd and restart, it still stops at the same point when I try again. The last attempt produced the following result:
d:\Workshop\dev\java\projects\default\spring-test-web>mvn archetype:generate
[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-assemb
ly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.jar
65 KB
Can anyone help me out with this? I'm using Windows 7 and Maven v3.0.3 which as far as I know is installed correctly.
Check if your development machine needs a HTTP proxy to access the internet - you might be able to establish this by checking your browser settings.
If you find you need a proxy server, see Maven - Configuring a proxy.
I have a similar problem on Windows Vista with just about everything Maven might want to download.
If I'm lucky can usually get around it by killing Maven (CTRL+C) and then re-running whatever task I was trying to do. Since Maven will only download the stuff once, the problem doesn't matter unless I'm using a plugin for the first time
UPDATE (V2)
I have this problem at work, but not at home.
I have AVG at work and not at home - at home I have Avast.
It works fine with the Link Scanner and Online Shield components disabled - your mileage may vary
I was having exactly the same problem and had AVG running virus check.
Temporarilly disabling it and restarting the mvn command worked perfectly.
I had the same problem and solved it with adding proxy in setings file in maven configuration.
Just add something like this:
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username></username>
<password></password>
<host>proxy.yourHost</host>
<port>8080</port>
<nonProxyHosts>yourHost</nonProxyHosts>
</proxy>

Resources