Maven is trying to install every jar from a private repository
The problem is that Maven Central as defined by Maven itself, in the super POM, always comes last in the repository order, so, projectx's S3 repo is being hit by many requests that fail and eventually AWS S3 temporarily blocks the client, before the projectxcommon
jar can be downloaded.
The only way to have Maven Central before the S3 repository is manually defining it in your pom.xml
before the projectx-aws
repo:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>projectX-aws</id>
<url>s3://projectX-support/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
More information about setting multiple repositories and their order can be found at:
- Setting up Multiple Repositories
- Repository search order
- https://stackoverflow.com/a/5325685/4704510
Some answers in Stack Overflow mention alphabetical order. At least in Maven 3 that is not true and only the order in which they are defined matters.
Probably main problem was with too many requests to Amazon S3
repository.
By analysing logs we can see over 120 request of downloading files from Amazon S3
in short time 1-3 seconds:
- Maven is downloading artefacts that don't exist in
Amazon S3
, then download it fromMaven Central
, those requests toAmazon S3
are useless - Every download needs a login and logout request, that's strange!
- Last 40 request are connection refused
- Last 40 request don't have [INFO] Logged in - projectx-support statement for them, so maybe some limits of log in in short time?
To solve the problem, there are atleast 2 solutions:
Force maven to download artefact FIRSTLY from
Maven Central
, then rest fromAmazon S3
, to decrease requests toAmazon S3
. This is a good solutions, but remember if you will have more artefacts to download only fromAmazon S3
you will get same problem!By default
Maven Central
comes LAST in repository, to set highest priority and download first fromMaven Center
, we have to add it manually in FIRST position in our repositories, because the order of the repositories will also DECIDE the order of the repository access. (Source):<repositories> <repository> <id>central</id> <name>Central Repository</name> <url>https://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>projectX-aws</id> <url>s3://projectX-support/maven2</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories>
- Find a way to change limits of requests by IP on
Amazon S3
repository. This solution will always works but your Amazon S3 will get many useless requests.
So the best way to solve the problem is to mix this two solutions. :)