Maven not working? - maven

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?

Related

mvn dependency:tree hangs trying to read repository

$ 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.

Trust repository with small dh key in maven build

When building my project using maven inside my newly setup CentOS 8 VM I get the following error when maven tries to download a dependecy from our internal nexus:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.120 s
[INFO] Finished at: 2020-03-25T17:43:34+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project myproject: Could not resolve dependencies for project our.domain:myproject:jar:1.5.0: Failed to collect dependencies at our.domain.internal:internal-commons:jar:0.12.3: Failed to read artifact descriptor for our.domain.internal:internal-commons:jar:0.12.3: Could not transfer artifact our.domain.internal:internal-commons:pom:0.12.3 from/to nexus-proxy (https://nexus.our.domain/repository/maven-public/): DH ServerKeyExchange does not comply to algorithm constraints -> [Help 1]
The problem also occurs when I try to read any webpage on that nexus:
[root#localhost Daisy]# curl https://nexus.our.domain
curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small
I tried to manually add the key to my known_hosts file using:
ssh-keyscan -p 443 nexus.our.domain >> ~/.ssh/known_hosts
But I returns without any console-output and no change to the file. Running
ssh-keyscan -p 443 nexus.our.domain
also produces no output at all.
I already reported the issue to the internal team that manages our nexus.
I would still appreciate any solution that forces my VM to accept the key of our nexus so I don't have to wait until the key is exchanged. I'm free to handle this in any level of my client (VM)-side (Maven, https, ssl or any lower level).
Versions used:
CentOS: CentOS Linux release 8.1.1911 (Core)
Maven:
[root#localhost Daisy]# mvn --version
Apache Maven 3.5.4 (Red Hat 3.5.4-5)
Maven home: /usr/share/maven
Java version: 11.0.5, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-147.5.1.el8_1.x86_64", arch: "amd64", family: "unix"
SSH: OpenSSH_8.0p1, OpenSSL 1.1.1c FIPS 28 May 2019
Changing the first line in /etc/crypto-policies/back-ends/opensslcnf.config :
- CipherString = #SECLEVEL=2:kEECDH:kRSA:kEDH:kPSK:kDHEPSK:kECDHEPSK:-aDSS:-3DES:!DES:!RC4:!RC2:!IDEA:-SEED:!eNULL:!aNULL:!MD5:-SHA384:-CAMELLIA:-ARIA:-AESCCM8
+ CipherString = #SECLEVEL=1:kEECDH:kRSA:kEDH:kPSK:kDHEPSK:kECDHEPSK:-aDSS:-3DES:!DES:!RC4:!RC2:!IDEA:-SEED:!eNULL:!aNULL:!MD5:-SHA384:-CAMELLIA:-ARIA:-AESCCM8
(changing SECLEVEL=2 to SECLEVEL=1)
For the maven build to run I had to change the jvm-setting as well:
What does "Reason: DHPublicKey does not comply to algorithm constraints" mean?
Remember, this is only a workaround. The setting is a security-setting and should normally not be changed.

Very Slow Maven

C:\eclipse\workspace>mvn --version
Apache Maven 3.5.2
Maven home: C:\apache\maven\bin\..
Java version: 1.7.0_65, vendor: Oracle Corporation
Java home: C:\Java\jdk1.7.0_65\jre
Default locale: en_US, platform encoding: Cp1252
C:\eclipse\workspace>mvn archetype:generate
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
Progress (1): 6.4 kB
Maven is very slow on my computer. I executed mvn archetype:generate and it's sitting at this point for 15 minutes. My internet connection is fast. I can download a large library from the internet in short time.
Can anyone suggest a solution?
Since maven does not work well at slow internet connection, local proxy and cache maybe good idea.
Repocache is remarkable.
Add repocache.cfg
[mvn.upstream.apache]
url = https://repo.maven.apache.org/maven2
This will cache package at mvn/releases.
Change $HOME/.m2/settings.xml add:
<repository>
<id>apache</id>
<url>http://127.0.0.1:5000/mvn/apache</url>
</repository>
This worked for me.
The problem may be a lost network disk connection. I had a similar issue. And after dropping the not available network disk, it started to work normally. More about this Slow maven unit tests

Maven in Ubuntu 10.4 -

This is my first time asking for help in a public forum.
So anyways Microsoft Windows has been my comfort zone as a development environment,recently I have been chucked into a linux environment at work, I seem to have got the hang of things, but when I tried to set up Maven2 I ran into some issues, I will get to the issue part later, but this is how I set up maven
Extracted maven to /usr/local/maven/apache-maven-2.2.1
Created a symbolic link to '/usr/bin' using following command
sudo ln -s /usr/local/maven/apache-maven-2.2.1 /usr/bin/mvn
when I mvn --version
Output :
Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530) Java version:
1.7.0_25 Java home: /usr/local/java/jdk1.7.0_25/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version:
"2.6.32-24-generic" arch: "i386" Family: "unix"
but when I try to do
mvn clean
Output :
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [clean]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.2/maven-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository central (http://repo1.maven.org/maven2): Error transferring file: repo1.maven.org
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.2/maven-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository central (http://repo1.maven.org/maven2): Error transferring file: repo1.maven.org
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Maven is trying to download a plugin it needs to to do project cleanup from http://repo1.maven.org/. Do you need to use a proxy to connect to the internet? If so, see this guide: http://maven.apache.org/guides/mini/guide-proxies.html
If not, it might be that the network somewhere between your workstation and repo1.maven.org was having problems, which might be resolved now.
The answer by Ireeder(Thanks man :-) ) did the trick.
My computer was behind a proxy, so I needed to do the following to allow maven access the Internet
Steps to solve it
Open the M2_HOME/conf/settings.xml
Look for this line block in the settings.xml
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>{username}</username>
<password> {password} </password>
<host>{host}</host>
<port>{port}</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
replace {value} with data relevant to you.
Enjoy!

maven generating pom file

I use maven 3.0.3 and have tried to generate pom for third-party jar like this:
mvn install:install-file -Dfile=cobra.jar -DgroupId=com.cobra
-DartifactId=cobra -Dversion=0.98.4 -Dpackaging=jar -DgeneratePom=true
According to link below it should generate proper pom.xml and install artifact in the repo.
http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html
Meanwhile, it returns such a error:
[ERROR] The goal you specified requires a project to execute but there
is no POM in this directory (D:\cobra-0.98.4\lib). Please verify you
invoked Maven from the correct directory. -> [Help 1]
Why is it asking for pom.xml while it should generate pom.xml?
This is an old question, but was a serious PITA for me for a few minutes, so I thought I'd share:
I just ran into this problem, and I believe that the issue is probably platform-dependent. The real tip-off was that the solution from Cyril's answer wasn't working as expected: despite my specification of -DgroupId=com.xyz and -DartifactId=whatever on the command-line and the corresponding entry in the POM file, the jar was installed in the local repo under com/whatever.
This led me to experiment with quoting command-line arguments, and the eventual correct result from formatting the command-line like this (after deleting the POM file):
mvn install:install-file "-Dfile=cobra.jar" "-DgroupId=com.cobra" "-DartifactId=cobra" "-Dversion=0.98.4" "-Dpackaging=jar" "-DgeneratePom=true"
Some of the quoting is doubtless redundant, but better safe than sorry, right? I happen to be running Vista on this computer, and would not be surprised if this problem were specific to this OS version...by the way, this was with Maven v3.0.4.
Are you sure that you are executing the install-file goal? I checked your command and it works for me, but when I place a blank install :install-file (maybe you have this typo) the install goal would be used which needs a pom.xml.
Try to use the -X parameter to get more debug information:
-X,--debug Produce execution debug output
My system
Maven
c:\>mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: C:\progs\apache-maven-3.0.3
Java version: 1.6.0_21, vendor: Sun Microsystems Inc.
Java home: c:\Program Files (x86)\Java\jdk1.6.0_21\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
Install Plugin
c:\>mvn -Dplugin=install help:describe
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install
This plugin has 3 goals:
install:help
Description: Display help information on maven-install-plugin.
Call
mvn install:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
install:install
Description: Installs the project's main artifact in the local repository.
install:install-file
Description: Installs a file in the local repository.
For more information, run 'mvn help:describe [...] -Ddetail'
I found a bypass. You need to create a simple pom.xml like this :
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cobra</groupId>
<artifactId>cobra</artifactId>
<version>0.98.4</version>
</project>
It's not perfect but it's worked for me. If you find a better way to do that, I'm interested.
My config :
$mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /usr/local/maven
Java version: 1.6.0_20, vendor: Sun Microsystems Inc.
Java home: /usr/local/jdk1.6.0_20/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-25-generic-pae", arch: "i386", family: "unix"
$mvn -Dplugin=install help:describe
...
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install
...
Try to run it on cmd.exe or execute cmd command before the mvn command.
Using maven version 3.6.3, this worked for me to generate pom file in my chosen directory:
C:<MyChosenDir> mvn archetype:generate "-DgroupId=com.mycompany.app" "-DartifactId=my-app" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DarchetypeVersion=1.4" "-DinteractiveMode=false"
just go under your project directory where you can find your pom.xml file then execute the same command ! it works for me ;)
If you are having trouble with the command line version of Maven, you might want to try the M2E plugin for eclipse. It is far more user friendly for people without very much experience with Maven.
It worked for me when I changed Powershell to Cygwin. Powershell is somehow parsing the command line argument incorrectly.
I had that error when I was using maven in Windows, what worked for me was opening the cmd and not the PowerShell.
Apparently certain errors appear when you don't do it with the cmd.
I hope it works.
If you are getting this error during jenkins pipeline setup , Then the error is we are placing git repository without .git in jenkins git url blank .Generally we put website url of git repo but we need to place clone url of git repo.Insert .git (cloned url) to website url , Simply insert git clone url.

Resources