Repository navigation
Description
Alan Czajkowski opened MNG-6397 and commented
Note: I am trying to do a build behind a firewall which means I cannot access the Internet, I can only access my internal Maven repository inside my network, so:
- grabbing artifacts from https://artifacts.example.com/repository/maven/ works fine
- grabbing artifacts from anywhere else fails due to firewall restrictions
Let's begin:
My pom.xml has the following:
...
<dependencies>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
...
</dependencies>
...
<repositories>
...
<repository>
<id>central</id>
<name>Public</name>
<url>https://artifacts.example.com/repository/maven/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
...
</repositories>
...The dependency:tree for the spring-boot-starter-web is as follows:
+- org.springframework.boot:spring-boot-starter-web:jar:2.0.0.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter-json:jar:2.0.0.RELEASE:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.4:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.4:compile
| | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.4:compile
| +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.0.RELEASE:compile
| | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.28:compile
| +- org.hibernate.validator:hibernate-validator:jar:6.0.7.Final:compile
| | +- javax.validation:validation-api:jar:2.0.1.Final:compile
| | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
| | \- com.fasterxml:classmate:jar:1.3.1:compile
| \- org.springframework:spring-web:jar:5.0.4.RELEASE:compileHow is it that the build fails as such:
...
Downloading: https://repo.spring.io/milestone/org/jboss/shrinkwrap/shrinkwrap-bom/1.2.3/shrinkwrap-bom-1.2.3.pom
Downloading: https://repo.spring.io/snapshot/org/jboss/shrinkwrap/shrinkwrap-bom/1.2.3/shrinkwrap-bom-1.2.3.pom
Downloading: https://dl.bintray.com/rabbitmq/maven-milestones/org/jboss/shrinkwrap/shrinkwrap-bom/1.2.3/shrinkwrap-bom-1.2.3.pom
Downloading: https://repo.maven.apache.org/maven2/org/jboss/shrinkwrap/shrinkwrap-bom/1.2.3/shrinkwrap-bom-1.2.3.pom
...
[ERROR] Failed to execute goal on project maven-multi-module-demo-backend: Could not resolve dependencies for project com.example.pipe:maven-multi-module-demo-backend:war:1.0.0-SNAPSHOT: Failed to collect dependencies at org.springframework.boot:spring-boot-starter-web:jar:2.0.0.RELEASE -> org.hibernate.validator:hibernate-validator:jar:6.0.7.Final: Failed to read artifact descriptor for org.hibernate.validator:hibernate-validator:jar:6.0.7.Final: Could not transfer artifact org.jboss.shrinkwrap:shrinkwrap-bom:pom:1.2.3 from/to spring-milestone (https://repo.spring.io/milestone): Connection reset -> [Help 1]
...when I did not even reference this repo spring-milestone ([https://repo.spring.io/milestone]) anywhere in my pom.xml?
When you go down the Spring Boot rabbit hole (go into the spring-boot-starter-web's pom.xml and then traverse up its parent-pom structure a few jumps) you'll eventually get to a parent-pom spring-boot-dependencies with this definition:
...
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>spring-milestone</id>
<name>Spring Milestone</name>
<url>https://repo.spring.io/milestone</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>spring-snapshot</id>
<name>Spring Snapshot</name>
<url>https://repo.spring.io/snapshot</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>rabbit-milestone</id>
<name>Rabbit Milestone</name>
<url>https://dl.bintray.com/rabbitmq/maven-milestones</url>
</repository>
</repositories>
...How is it that the Maven build does not even attempt to reach out to https://artifacts.example.com/repository/maven/ to try to find the missing dependency shrinkwrap-bom? and only reaches out to the above repos only and not the one defined in my own pom.xml?
This seems like a transitive dependency resolution bug to me as the Maven build does not even make a single attempt at trying to get shrinkwrap-bom from the <repository> that I have explicitly defined in my pom.xml. The (grand)parents of the spring-boot-starter-web dependency completely hi-jack the repository list that the build pulls from (this type of hi-jacking should not be allowed). The shrinkwrap-bom artifact does exist in [https://artifacts.example.com/repository/maven/] and can be fetched no problem if it is explicitly defined in my pom.xml but defining it explicitly would be a work-around and I cannot use this work-around in my situation.
Affects: 3.0, 3.5.0, 3.5.2, 3.5.3, 3.6.0, 3.6.1, 3.6.3
Issue Links:
-
MNG-6772 Super POM overwrites remapped central repository in nested dependencyManagement import POMs
("is caused by") -
MRESOLVER-168 add DEBUG message when downloading an artifact from repositories
-
MNG-7094 Assure in an IT that reactor repository definitions are not used when Model Builder downloads dependencies with scope import
Backported to: waiting-for-feedback
1 votes, 15 watchers
Activity
jira-importer commentedon Apr 19, 2018
Karl Heinz Marbaise commented
You should configure your repository manager correctly in your
settings.xmland define amirrorOf entry to redirect all request to your internal repository manager ...
It also interesting to see things like this:
: Connection reset -> [Help 1]...?jira-importer commentedon Apr 20, 2018
Alan Czajkowski commented
Karl Heinz Marbaise
I appreciate your "work around" suggestion, and I've already thought of trying this, but this is not an acceptable solution for me as this build goes into a build system where I am not able to modify any
settings.xmlfile. Everything related to the build must be completely self-contained inside thepom.xml, as this is a natural expectation of Maven, hence why I am logging this as a "bug" because the build should work naturally without me having to define mirrors.It is not interesting to see
Connection resetbecause at the very beginning of the description I explained the firewall situation. The firewall here is not causing anything to break in Maven. Maven is simply ignoring/not respecting my<repository>definition in my ownpom.xml.jira-importer commentedon May 9, 2018
Alan Czajkowski commented
Work-around #1:
settings.xmlWork-around #2:
pom.xml, keep the<id>tags the same, and then do your own hi-jacking of the<url>tags inside the<repository>definitions, like so:jira-importer commentedon May 9, 2018
Alan Czajkowski commented
is anybody looking into this bug?
jira-importer commentedon May 9, 2018
Karl Heinz Marbaise commented
If you don't like my "work around" sorry...the
settings.xmlis the solution to that particular problem. If you have already a build system this should already being configured correctly that way otherwise it not correctly configured (for example you should use config file provider plugin which offers this exactly for the settings.xml) ...I would suggest to define a
<mirrorOf>*</mirrorOf>which is easier...The point is that you are expecting to overwrite the repository definitions of the dependencies/transitive dependencies which is not possible by using a repository entry in the pom.
The point is that each pom/artifact maintainer can put repository definitions into their pom file (which is not a good idea cause it exactly happens what here is described...different story)...which results in exactly this situation. There for you have the option via
settings.xmland define a mirror which redirects all request from each pom through the given mirror.If you don't like the solution or is not acceptable for you than please provide a patch(es) to solve it the way you like it...
jira-importer commentedon May 9, 2018
Alan Czajkowski commented
Karl Heinz Marbaise
To be clear: this is a bug that needs to be fixed
"The point is that you are expecting to overwrite the repository definitions of the dependencies/transitive dependencies which is not possible by using a repository entry in the pom." <-- this is not true, my simple expectation is that the Maven build at least try to attempt to reach out to the repo that i have in my own pom.xml alongside the repos defined in the dependency pom.xml <-- this is a reasonable expectation of Maven
Your dependencies whether transitive or not, should not be allowed to do a complete hi-jacking of the list of repositories that the Maven build pulls from, which is what is happening here <-- that is the bug, the hi-jacking part
the mirror work-around is not possible as i am not allowed to modify the current build system in place, which means the only way forward is to either explicitly define all of the problematic dependencies in my pom.xml (a very tedious and horrible solution), or do the second work-around i mentioned above by re-hi-jacking the repos again ... none of these work-arounds are ideal, nor do they follow reasonable expectations of Maven
jira-importer commentedon Jun 24, 2019
Alan Czajkowski commented
this is a common problem that comes up regularly in the various projects that I work on (especially projects that use Spring Boot and the Spring Boot parent in their projects), and I have to use the mirror work-around in the settings.xml (which is a poor solution)
is anybody looking into this?
jira-importer commentedon Oct 1, 2019
Eddie Wiegers commented
I just ran into a similar-sounding issue that based on your build output looks like it may be the same root cause. I have logged a separate issue (MNG-6772) to provide my investigation notes, but wanted to give a heads up that it looks like the same root issue.
jira-importer commentedon Oct 1, 2019
Alan Czajkowski commented
Eddie Wiegers unfortunately, I don't think anybody is looking into this or taking it seriously :(
jira-importer commentedon Oct 4, 2019
Eddie Wiegers commented
I submitted a fix, so if it gets accepted hopefully this will be resolved in Maven 3.6.3.
jira-importer commentedon Oct 4, 2019
Alan Czajkowski commented
Eddie Wiegers amazing, thank you!
jira-importer commentedon Nov 9, 2019
Fan Guogang commented
mirrorOf * is not a good option, for example if you use a hosted repository server, such as nexus or artifactory, you need to create a group contains all repositories,that will cause slow performance when resloving dependencies, because nexus will need to contact all repositories to get metadata.
jira-importer commentedon Feb 10, 2020
Alan Czajkowski commented
Karl Heinz Marbaise can we get Eddie Wiegers's fix accepted?
jira-importer commentedon Feb 25, 2020
Elliotte Rusty Harold commented
sounds like the decision here is won't fix, WAI. Should we close the bug?
jira-importer commentedon Feb 26, 2020
Alan Czajkowski commented
why would this be closed? this is a legitimate problem with Maven dependency resolution, and becoming a more prominent problem with the proliferation of Spring Boot
10 remaining items
jira-importer commentedon Aug 29, 2020
brian clozel commented
This issue bothers me in many ways.
??Spring Boot takes the non-standard approach of forcing you to reference their parent POM instead of simply just referencing Spring Boot as a dependency in your project POM. As a result, the dependency graph is hi-jacked by Spring Boot because the graph root does not hinge on your project POM as the root of the graph, like it would in a normal Maven project, instead your project POM just becomes a child in the puppet-mastery of the Spring Boot parent POM, and you, as a developer, are no longer in control of the build in its entirety – and this scenario of "loss of control" has exposed a certain edge-case bug in how all of the dependencies of the entire dependency graph get downloaded.??
First, there are many ways to use Spring Boot: you can choose a build tool, or just import
spring-boot-dependenciesas a BOM and take full control of your POM hierarchy. We do recommend importing the Spring Boot parent (and that's what we do on start.spring.io), because we think this is the best approach to support our users on Maven. How is this approach "non standard" and what is the standard you're referring to? Of course Spring libraries can be consumed as regular dependencies, but in this case Spring Boot does much more than a library.Also, why people here would assume that Spring Boot is forcing those repositories declarations on purpose? Do Spring projects have an history of being bad Maven citizens?
A quick look on search.maven.org shows that Spring Boot
2.0.0.RELEASEis the only version declaring those repositories in our dependencies module. Another quick search in the Spring Boot tracker shows that we noticed that problem ourselves and this was quickly addressed in2.0.1.RELEASE, released a month after2.0.0.RELEASE.Finally, why are Spring developers being pulled here for a one-off, 2 year-old problem on a POM (fixed a month after it appeared) on a Spring Boot generation that is now EOL? The best workaround here is to upgrade to
2.0.1.RELEASEor better, upgrade to a version that is suported officially by the Spring team.If there are any issues with POMs Spring Boot is publishing, please create an issue on our tracker.
jira-importer commentedon Aug 31, 2020
Alan Czajkowski commented
brian clozel
To be clear, this issue that I have raised in this ticket, is something that I believe is a bug in how Maven decides to download the entire dependency graph if it is not rooted at your project's POM (i.e. referring to a parent POM makes your project not the root of the dependency graph). I'm not blaming Spring Boot for this problem, this is a Maven problem.
That being said ... there's plenty to rant about Spring Boot's approach. This ticket is not the appropriate place to do it, but i'll do it anyway since you're here ...
As for Spring Boot, what is non-standard about referring to a parent POM for an external dependency (such as Spring Boot)?
${and}and Spring Boot forces you to use@instead: this is a major intrusion to a project. I completely understand why Spring Boot chose to do this, so that Maven's resource filtering and variable interpolation does not conflict with Spring's Expression Language (SpEL), but still ...jira-importer commentedon Aug 31, 2020
Stephane Nicoll commented
It doesn't do that in any way. As Brian indicated, you don't have to use the parent if you don't want to (have you looked at the references he shared before replying)? Even if you do, you can easily override the resources filtering configuration to use whatever placeholders you fancy.
Given the italics in "highly", I suspect you believe that's true. It isn't.
I think Brian already showcased we're happy to improve things based on constructive feedback. Spring Boot lets you chose your own parent. You can chose to import our BOM there or manage things yourself completely. Of course, doing so may mean more work for you.
jira-importer commentedon Aug 31, 2020
Alan Czajkowski commented
Stephane Nicoll this ticket was created in 2018, way before any of that "convenient" Spring Boot documentation existed or BOM options were available ...
once again, this ticket is for a bug-fix in Maven, not for Spring Boot to improve anything, because if someone chooses to go the Spring Boot parent POM route, and they are sitting behind a firewall that blocks internet access, then they are going to run into this Maven issue
jira-importer commentedon Sep 1, 2020
Sylwester Lachiewicz commented
Alan Czajkowski I've merged changes for MNG-6772 to master, please check if this also resolved your case.
Please run build yourself or use artifacts for 3.70-SNAPSHOT from our Jenkins: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven/job/master/
jira-importer commentedon Nov 21, 2020
Michael Osipov commented
Please read my comment in https://issues.apache.org/jira/browse/MNG-6772?focusedCommentId=17236781&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17236781. This change adds a loop hole for a lot of problems.
jira-importer commentedon Nov 23, 2020
Alan Czajkowski commented
Michael Osipov why does this add a loop-hole? all this this ticket requests is that dependency resolution include whatever repositories are mentioned in the project's pom.xml, not override anything in parent and/or sibling pom.xml files in the dependency tree
therefore if we are not overriding, why is this a problem?
jira-importer commentedon Dec 2, 2020
Michael Osipov commented
Alan Czajkowski, let me try a few tests behind Nexus. Also read my comments in MNG-6772. This is a duplicate issue for me. If not, please explain why.
jira-importer commentedon Dec 2, 2020
Michael Osipov commented
I applied the following patch to Core ITs:
and the test passed. From my POV, as said before, the fix and tests are logically broken. If your problem differs present a different IT, I'd be happy to evaluate.
jira-importer commentedon Feb 9, 2021
Hervé Boutemy commented
just changed link to MNG-6772: the current issue is caused by MNG-6772 = handling of import-scoped dependencies (in dependencyManagement) by Model Builder does not work the same way as "normal" dependencies by lifecycle
(no judgment at this stage if we should change that nor if we can: it's just a description of what is happening, that will be shown in future IT through MNG-7094)
jira-importer commentedon Apr 11, 2021
Hervé Boutemy commented
to ease debugging of repositories order when resolving an artifact, I implemented MRESOLVER-168