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

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.

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

Intermittent 401 error from Artifactory when deploying files

During our intraday builds, we intermittently (perhaps twice a day) get a '401 Unauthorized' error when maven performs the 'deploy' step of the build. This error is seen on both the maven console and in the Artifactory requests.log. The time of day isn't consistent, nor is it tied to a snapshot/release repository. I've checked and doublechecked all security settings and urls, and since this error is intermittent, I'm confident the issue lies with Artifactory.
I also get this intermittently with a 'mvn deploy:deploy-file'. Today it failed on 1 upload out of approx 300.
I've raised a jira with Artifactory but it's not been picked up yet: https://www.jfrog.com/jira/browse/RTFACT-14982
I should add that we didn't encounter this issue when using Archiva as our repository. It's happened regularly since I migrated to Artifactory
With regards to the pom.xml example, the reason it is failing is that the deploy-file goal is missing the repositoryId property.
This property should include the repository id for the repository you use for deployment, for example:
<repositoryId>internal-snapshot-local</repositoryId>
The plugin will use this id for getting the deployer credentials from the Maven settings.xml file.

Maven Error: No plugin found for prefix ‘archetype’ in the current project using Nexus

I am trying to setup MAVEN in my company's local network which is not connected to the internet directly. Also I'm using sonatype nexus for my central repository.
Problem starts when I run the command mvn archetype:create. The result is always build failure.
error no plugin found for prefix 'archetype' in the current project.
How do I solve this issue?
Maven is trying to look up the full plugin artifact ID that corresponds the "archetype" prefix.
To do this it reads the available prefixes from this path: /org/apache/maven/plugins/maven-metadata.xml
Since you're using Nexus this is likely coming from a group repository, e.g.:
http://:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml
You'll need to look carefully at your maven configuration and your build log to see where exactly it is trying to retrieve this information. There will likely be additional information about the failure if you run Maven with the debug ("-X") flag.
If it's trying to retrieve it from your Nexus instance see here for information on how to diagnose the issue:
https://support.sonatype.com/entries/21437881

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

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

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>

Resources