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

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

Related

maven .pom and . pom.shal1 files not getting updated

I am trying to install maven for the 1st time and seeing below issues when trying to do a maven force update to get the jars to my local repository. I am able to see the property file, jar and jar.sha1 but the .pom and .pom.sha1 is not getting updated. When i go to the specific folder i see this file instead
maven-clean-plugin-3.0.0.pom.lastUpdated
This is happening to all the folders in my repository. The content inside this .lastUpdated file is
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Sat Nov 04 22:38:58 EDT 2017
https\://artifactory.cen.gov/artifactory/repo/.error=Could not transfer artifact org.apache.maven.plugins\:maven-clean-plugin\:pom\:3.0.0 from/to repo (https\://artifactory.cen.gov/artifactory/repo)\: com.ibm.jsse2.util.h\: PKIX path building failed\: java.security.cert.CertPathBuilderException\: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is\: \n\tjava.security.cert.CertPathValidatorException\: The certificate issued by CN\=CENInternalRootCA, OU\=cen Service, O\=U.S. Government, C\=US is not trusted; internal cause is\: \n\tjava.security.cert.CertPathValidatorException\: Certificate chaining error
#proxy.cen.gov\:8080>#default-repo-https\://artifactory.cen.gov/artifactory/repo/.lastUpdated=1509849538349
I had this certificate chaining exception earlier but got rid after adding proper certificate and creating keystore and adding them to env variables.
Because of this error i am not able to do a maven clean or run as maven install.
Any suggestions please?
When you already got rid of your certificate problem, you can force an update by using
mvn clean install -U
-U,--update-snapshots Forces a check for missing
releases and updated snapshots on
remote repositories
Otherwise you can delete your local repository. This is a very effective way to force Maven to re-download all dependencies, but the next build may take a substantial ammount of time, depending on the number of dependencies.
The repository is located in ~/.m2/repository by default. Otherwise its location is configured by the <localRepository> setting in settings.xml.
See also Force maven update
If the problem with your certificate chain still exists, Maven will not be able to download the dependencies and you will get the same .lastUpdated files again

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 3 Nexus - Unable to download artifacts from remote Repository

I have a Maven 3 Nexus installed on a server. Through the Nexus GUI, I have added a proxy repository of repository policy as "Snapshot" and the URL is a remote Vendor URL, from where the artifacts/plugins are required to be downloaded. Then I have added the newly added proxy repository to the Public Repositories under Ordered Group Repositories.
Post the above activity, I have tried to build the project using mvn clean install. However the build is failing due to missing artefacts from vendor URL.
In Nexus, when I go under the Public repository and look under Browse storage, I do not see the artefact folder, which should have been downloaded from remote repository.
The "Browse remote" on the newly created repository is working fine and I can navigate to the required artifacts.
I am not sure what I am doing wrong. Any help is much appreciated.
If while the first run of :
mvn clean install
the required artefact was not available on Nexus, maybe it is now cache localy (on your laptop) as not found.
Maybe you just have to tell maven to update cache using -U option ?
mvn clean install -U
The other solution could be a mismatch snapshot/release repository information. Check your Repository policy proxy configuration on your Nexus server proxy.

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.

maven could not resolve dependency via my local nexus repository

I have setup an in-house Sonatype Nexus repository and configure the maven to check my local Nexus instead of getting artifacts directly from public repositories.
http://www.sonatype.com/books/nexus-book/reference/config-sect-intro.html
Our project was able to download the most artifacts except one artifact in Maven central.
Here is the build error:
Failed to execute goal on project shindig-gadgets: Could not resolve dependencies for project org.apache.shindig:shindig-gadgets:jar:3.0.0-SNAPSHOT: Could not find artifact com.ibm.icu:icu4j:jar:4.6 in nexus (http://my_nexus_repository:8081/nexus/content/groups/public) -> [Help 1]
I see that icu4j-4.6.jar does exist in the Maven central repository. On my local nexus repository, it doesn't exist. I see only icu4j-4.6.pom exists on my local nexus repository.
It's not like my nexus repository setting is totally broken. maven project has successfully downloaded numerous jar files from multiple public repositories via my local nexus maven repository except icu4j-4.6.jar.
I don't understand why I'm having a problem with only icu4j-4.6.jar. Would it be incorrectly cached on either my local maven or nexus maven repository?
If it was incorrectly cached, how can I clean the local maven or nexus maven repository?
The similar problem is described at
Missing maven dependency using nexus setup
icu4j-4.6.jar does not show up in the search list. Only icu4j-4.6.pom shows up in the search list. I don't think is Snapshot VS Release issue because icu4j-4.6.jar seems release jar.
Is it possible that the nexus repo just stopped responding for a while? You can try mvn -X (or -d?) to get detailed info about what is going on. You might also try configuring an alternative repo.
Perhaps you haven't enabled remote index downloads from Maven Central. This would explain why only the POM file appears in your local search (The only file which has been downloaded via the proxy repo).
There might be another issue causing the download failure for the jar itself.... I suppose try and solve one problem at a time :-)
Try adding -U to your mvn arguments to force an update of your local repository.
You could also have corrupt meta data in the repo. In which case, delete that artifact from the repo's cache and let it refresh.
If the artifact in question was cached in properly from the proxy repository, using mvn -U will fix the problem
However if you are seeing pom on your nexus ,this usually happens when the artifact from the proxy repository is not cached in properly. The way to fix is
1) Browse to the component in the Proxy Repository.
2) Invalidate the cache for the repository and reindex the Nexus repository.
3) run mvn clean -U

Resources