spring-bootmaven

Maven build is failing with compilation error for spring boot app after Sept-29th 2024


I started to see a very weird behavior on spring-boot 2.5.3 after 29th of September 2024.

I have a code base that depends on spring-boot 2.5.3 and below is the list of spring related dependencies:

spring-cloud-starter-contract-stub-runner
spring-boot-starter-test
spring-cloud-starter-sleuth
spring-cloud-starter-contract-stub-runner
spring-boot-starter-web
springdoc-openapi-maven-plugin
spring-cloud-starter-openfeign
spring-boot-starter-validation
springdoc-openapi-webmvc-core

Starting the mentioned date, I started to see all my CI jobs are failing with compilation error with no code changes, getting the below

[ERROR]package org.springframework.cloud.openfeign does not exist
[ERROR] <class-full-path> cannot find symbol
                                 symbol: class FeignClient

I did all kinds of debugging for maven

mvn dependency:tree -Dverbose > dep6.tree
mvn dependency:go-offline > dep.offline

#build the code with a clean m2 repo and with debug logging
mvn clean package -Dmaven.repo.local=./empty-m2 -DskipTests -X

Edit: maven version 3.8.1


Solution

  • I was 100% sure that it was a maven dependency or repository issue, but I was not able to find the clue or the pointer.

    TLDR; some of the depdencies were depending on a repo named -> https://maven.restlet.org/ but this repo is not valid anymore and pointing to a website https://restlet.talend.com/.

    I had to update my settings.xml to be something like this, so that i will override all report and fallback on https://repo.maven.apache.org/maven2/:

    <settings>
        <mirrors>
            <mirror>
                <id>central-only</id>
                <mirrorOf>*</mirrorOf>
                <url>https://repo.maven.apache.org/maven2/</url>
            </mirror>
        </mirrors>
    </settings>
    
    

    Details and Steps of reproduction:

    [WARNING] Checksum validation failed, expected <!doctype but is a0023349b1f10ff1457077b4f4f49f7015c00b6a from maven-restlet for https://maven.restlet.org/org/springframework/security/spring-security-bom/<version>/spring-security-bom-<version>.pom
    
    [WARNING] The POM for org.springframework.cloud:spring-cloud-starter-contract-stub-runner:jar:<version> is invalid, transitive dependencies (if any) will not be available: 17 problems were encountered while building the effective model for org.springframework.cloud:spring-cloud-starter-contract-stub-runner:<version>
            [FATAL] Non-parseable POM /app/./empty-m2/com/datastax/oss/java-driver-bom/4.9.0/java-driver-bom-4.9.0.pom: unexpected markup <!d (position: START_DOCUMENT seen <!d... @1:3)  @ /app/./empty-m2/com/datastax/oss/java-driver-bom/<version>/java-driver-bom-<version>.pom, line 1, column 3
            [FATAL] Non-parseable POM /app/./empty-m2/org/codehaus/groovy/groovy-bom/<version></version>>/groovy-bom-<version></version>>.pom: unexpected markup <!d (position: START_DOCUMENT seen <!d... @1:3)  @ /app/./empty-m2/org/codehaus/groovy/groovy-bom/<version></version>>/groovy-bom-<version></version>>.pom, line 1, column 3
            [FATAL] Non-parseable POM /app/./empty-m2/org/infinispan/infinispan-bom/<version></version>>.Final/infinispan-bom-<version></version>>.Final.pom: unexpected markup <!d (position: START_DOCUMENT seen <!d... @1:3)  @ /app/./empty-m2/org/infinispan/infinispan-bom/<version></version>>.Final/infinispan-bom-<version></version>>.Final.pom, line 1, column 3
    
    

    At this point, it was very rationale to get the code not compiling due to that fact that there are lots of dependencies maven was not able to resolve, hence compilation error.

    As you can see from the logs above, multiple pom files are not resolving to a valid pom structured file, but it resolves to a normal html page.

    After applying the maven mirror mapping in the settings.xml everything get back to normal, I hope this save time for others.