Sometimes you'll receive 404 responses when trying to retrieve artifacts from a repository, but you know the artifact is present in the server.
There are a number of things which can cause this.
NFC ( Not found Cache )
Artifacts may be in the NFC (not found cache). Nexus caches items which are not found in a repository for a period of time specified in the repository's configuration. This is done for performance reasons. Typical reasons for artifacts to be in NFC:
- The repository is a proxy, and an attempt was made to retrieve the artifact before it was available on the remote
- User has manually restored artifacts into a hosted repository (retrieved them from Nexus trash, for instance).
To clear the cache, have the user right click on the repository and run "expire cache". Note that group repositories do not have an NFC cache, only repositories contained in groups.
Nexus Configuration Problems
- The hosted/proxy repository is not in the group repository.
- There is a repository route defined which is preventing access to the GAV from the group repository.
Most likely cause is a firewall which has virus scanning turned on. User can work around by increasing the HTTP read timeouts in Nexus (either globally or per proxy repository).
Note: Usually the end user is unaware that IT has changed the firewall, so it may not be obvious this could be the real problem.
SNAPSHOT look-ups, or version ranges, or unversioned dependencies (typically plugins) will trigger metadata look-up. If the version referenced by the maven-metadata.xml is not there you will get a 404.
This can usually be fixed by running rebuild metadata on the affected artifact.
Maven POM Dependency Typos
This actually happens more often than you might think - there is a typo in the pom.xml dependency.
Make sure the GAV Maven is looking for matches what is in the repository.
One nice technique is to find the artifact in Nexus UI and paste the XML from the Artifact information panel into the pom.xml. This demonstrates a nice way to avoid this problem in the future.
Maven settings.xml or POM repository config blocking downloads
if you have a mirror or repository defined in your settings.xml or POM, make sure it is configured to allow both releases and snapshots. When Maven decides it should block using a repository to download a release or SNAPSHOT based on this criteria, it does not provide a message indicating this was why.
Diagnose with Nexus using ?describe
Nexus contains a mechanism for diagnosing reasons why an artifact isn't found. You can add "?describe" onto the end of an artifact's URL. For more information read this article.