Maven error: Unable to get resource / Server redirected too many times - maven

Our proxy went down and I tried to update dependencies with Maven while it was off.
Since then I can't download anything with Maven.
I get this error for everything.
I tried -U option, deleting my local repository and tried different Maven version (2.0.9, 2.2.1) but it doesn't work.
Any idea how to solve this?
Earlier it also said 'repository will be blacklisted' to all of them.
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.1/maven-compiler-plugin-2.1.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-compiler-plugin:pom:2.1' from repository central (http://repo1.maven.org/maven2): Error transferring file: Server redirected too many times (20)
org.apache.maven.plugins:maven-compiler-plugin:pom:2.1
from the specified remote repositories:
jboss-snapshot (http://snapshots.jboss.org/maven2),
central (http://repo1.maven.org/maven2),
JBoss Repo (http://repository.jboss.com/maven2),
spring-maven-snapshot (http://maven.springframework.org/snapshot),
com.springsource.repository.bundles.external (http://repository.springsource.com/maven/bundles/external),
com.springsource.repository.bundles.snapshot (http://repository.springsource.com/maven/bundles/snapshot),
jboss (http://repository.jboss.com/maven2),
com.springsource.repository.bundles.release (http://repository.springsource.com/maven/bundles/release),
jboss-snapshot-plugins (http://snapshots.jboss.org/maven2),
com.springsource.repository.bundles.milestone (http://repository.springsource.com/maven/bundles/milestone),
jboss-plugins (http://repository.jboss.com/maven2)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)
... 25 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
... 27 more

I got the same error with Windows ISA proxy.
I had to put my Windows domain name and username in ~/.m2/settings.xml like this:
<username>DOMAIN\USERNAME</username>

I don't know how this solved it but I changed my password (domain/proxy) and now it works.

I had same problem.
The problem is 'domain' in file settings.xml
<proxy>
...
<username>DOMAIN\user</username>
...
</proxy>
DOMAIN is optional if you launch maven in Microsoft Systems but it is mandatory if you launch maven in UNIX systems with domain authentication and remapped user (user home is in /home/DOMAIN/user), I found this trick in empiric way.

Something that happened to me was that when I installed Maven, it added proxy information in ~/.m2/settings.xml. I don't have a proxy, so I'm not sure where it came from, but that prevented me from being able to download anything. After removing the proxy info, downloads were successful.

If you need a proxy server section, but want to connect to a repository on the intranet you can add an exclusion list: <nonProxyHosts>localhost|repoHost<nonProxyHosts>

Related

I have a problem with Maven 3.8.4 that not allowed to authorize our private repo on Apache Archiva

I have installed Maven 3.8.4 with homebrew on Macbook M1 CPU recently and I have ~/.m2/settings.xml properly containing the Apache Archiva user name and password.
when I executed mvn help:effective-settings -DshowPasswords=true command I can see the correct xml content. But when I run mvn clean package I get something like that
Failed to read artifact descriptor for company.webshop:webshop-common:jar:21.11.12:
Could not transfer artifact company.webshop:webshop-common:pom:21.11.12
from/to company (https://repo.company.com/repository/internal/):
authorization failed for https://repo.company.com/repository/internal/company/webshop/webshop-
common/21.11.12/webshop-common-21.11.12.pom,
status: 403 Forbidden -> [Help 1]
when I try to access https://repo.company.com/repository/internal/ address from my browser I can login and see the artifacts properly as well. More than that other team members don't live any problem.
I also removed maven and reinstalled but nothing changed.
any idea?
I noticed that after removing the folders (under the .m2 folder) related to our private repo, and re-run the maven after a fresh instalment it's working properly.
Maven was not downloading the artifacts I guess, since there is a folder of that version number and only showing the content of old files which says something like "not authorized to the repo." and was miss leading

Maven: All Plugins & Dependencies are underlined Red

ANY IDEAS?? I downloaded a Maven project for IntelliJ and cannot build it. I get errors for dependencies and plugins:
(SOLVED: THIS was because I was trying to run it on my work laptop in work, and the company firewall was blocking me from downloading from the public Maven repository. Thank you)
VIEW BUILD LOG HERE
VIEW IDEA LOG HERE
From reviewing the log files, its as people have mentioned IntelliJ is not able to actually download the dependencies.
The reason why is:
Caused by: java.lang.RuntimeException:
org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework:spring-aop:pom:4.1.2.RELEASE from/to central (https://repo.maven.apache.org/maven2):
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
This typically can occur when all your external traffic is being routed by a corporate proxy that is performing a man-in-the-middle type of scan where the traffic is decrypted, scanned and then re-encrypted.
We experience the same thing in our office so our solution was:
Install your own version of the java SDK (Ex. using SDKMan)
In your new install import into the default trust store the certificates required to validate the new certificate chain
Helps to access the URL in Chrome to view the certificate chain)
If it doesn't look like the Screenshot then there is a proxy
Update IntelliJ so the Project SDK is the new one
Update IntelliJ so JDK for importer is the new one
Click the Reimport All Maven Projects in IntelliJ
This should allow it to continue to work without problems, alternatively in IntelliJ you can run the adhoc maven goal of:
mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
And it should install all the required dependencies into the local maven cache by ignoring all the SSL certificate problems however this is generally a bad idea.
At this point you can then click the Reimport All Maven Projects in IntelliJ to have it refresh but I found this always doesn't work as IntelliJ sometimes downloads additional plugin dependencies that it can get hung up on that are outside of the clean install goals.

Maven 2 works but Maven 3 gives authentication error with same settings and server

I'm setting up a new archiva server and a new project. Right now I have a very simple pom and nothing really that interesting on the server.
When I 'mvn compile -U' using maven2 from the command line I'm able to access my archiva server and download a plugin as part of the build. However, when I switch to maven3 (same settings.xml) I get an error when I 'mvn compile -U':
Plugin org.codehaus.mojo:exec-maven-plugin:1.4.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:exec-maven-plugin:jar:1.4.0: Could not transfer artifact org.codehaus.mojo:exec-maven-plugin:pom:1.4.0 from/to central-proxy (http://archiva.myserver.com/repository/internal): Not authorized , ReasonPhrase:Unauthorized.
I don't see anything interesting in the debug info when I build with the '-X' flag, and I don't see anything on the server log files either.
Right now I'm using only the username and password fields in my settings.xml. From the documention, I should be able to just use those fields - privateKey is optional.
Anyone else have problems when switching between maven2 and maven3 with the same settings?
After spending a day or two trying to figure this out, it looked to me as if maven3 was not sending my credentials. So instead of using the username and password fields I embedded my credentials in the urls to my repositories, such as:
<url>http://username:password#archiva.mydomain.com/repository/internal/</url>
This works. I no longer it an unauthorized error from the server.

Maven - unable to download dependencies behind Proxy Error Code - 307 Temporary Redirect

I am using Maven to run a Java project. My issue is that I am not able to download the dependencies. It is giving the following error
[ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:2.7.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.7.1: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2): Failed to transfer http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.7.1/maven-surefire-plugin-2.7.1.pom. Error code 307, Temporary Redirect -> [Help 1]
The settings.xml is properly configured with the proxy details (since I am behind a proxy) Still, I am not able to access the maven repo to download.
UPDATE: Thanks a lot landal79.I revisited this issue after some time. Still this issue gives me a nightmare.
Currently, I am not able to create any Maven Project. I am 100% sure this is due to a proxy issue. But not able to
nail it down to where exactly the issue.
When I try creating a project selecting an archetype, I am not able to create a maven project. I am getting the below error
"Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-
quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Users\rrr.m2\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Users\rrr.m2\repository)"
I try creating this project through Eclipse. The settings.xml point to the right proxy ( cross checked with the Network connections dialog (window ->General->NetworkConenction Dialog). But the issue still persists.
So what I did was installed standalone Maven and create a maven project from command prompt. To my surprise,I am not able to download the archetypes in Maven Repo though other plugins are getting downloaded (Surefire plugin and JUNit jar for example)
Is there any work around to resolve the archetype download issue?
I tried your solution, but the issue still persists. When I create a simple maven project (without using any archetypes) I am getting "Unable to build Project " Error
PS: The proxy settings are defined in settings.xml and they are correct. Also, the eclipse proxy settings are correct (Since I am able to install plugins from Eclipse MarketPlace)
Eclipse experts - please help me resolve this issue. Thanks a lot in advance for help.
Thanks

Service unavailable error while building using Maven

I am a newbie to Maven.
First time I run the mvn clean install command and it gave me the below error:
[ERROR] Non-resolvable parent POM: Could not transfer artifact
com.sybase365.mobiliser:mobiliser-parent:pom:4.6.0-RC02 from/to repo
(http://orinoco.sybase.com/nexus/content/groups/public-devel): Failed
to transfer file:
http://orinoco.sybase.com/nexus/content/groups/public-devel/com/sybase365/mobiliser/mobiliser-parent/4.6.0-RC02/mobiliser-parent-4.6.0-RC02.pom.
Return code is: 503, ReasonPhrase:Service Temporarily Unavailable. and
'parent.relativePath' points at wrong local POM # line 3, column 11 ->
How do I resolve this error?
Your remote repository is inaccessible. See explanation for error 503 in here.
I think i found the reason it gives 503. In my case this was a proxy issues inspite of excluding hosts that belong to a certain domain.
Remove the proxy from manage jenkins -> manage plugin -> advanced and try again
Could be, also I find this error happens all the time when the repo is available and downloading the file manually from the nexus GUI works. For some reason maven looks in the wrong repository location. If it happens for one jar and its pom you can down load the file by hand.
If maven ever hits a temporary HTTP problem it stores a lastUpdated file that you need to delete or it will not try to download the file again for a while.
sudo updatedb && locate lastUpdated | xargs rm
Or scrabble around in explorer in /Users/username/.m2/repository to find the files if you use windoze
Another thing that can mess with repo access is the proxy that maven uses. Check the contents of ~/.m2/settings.xml or create this file and setup what ever HTTP proxies or lack there of that you need to access the repos you have configured in poms.

Resources