I'm migrating an app to use ehcache 3.10.0 but getting a build error: Could not find artifact javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 in central (https://repo1.maven.org/maven2)

I see the file in my local .m2 directory: .m2\repository\javax\xml\bind\jaxb-api -- 2.3.0-b161121.1438

So that's an IDE issue for why it's not seen in my local build, since it does exist on my local .m2, but this version (2.3.0-b161121.1438) is still not available on maven, https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/

So the build fails with that artifact error. Any tips on how to resolve it?

1

There are 1 best solutions below

2
On

A similar issue has been reported on the ehcache3 github: https://github.com/ehcache/ehcache3/issues/2881

This dependency is causing the issue, from the ehcache pom.xml: https://search.maven.org/artifact/org.ehcache/ehcache/3.10.0/jar

    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <version>[2.2,3)</version>
      <scope>runtime</scope>
    </dependency>

Due to the open ended version the following dependency chain is causing this issue: Failed to collect dependencies at org.ehcache:ehcache:jar:3.10.0 -> org.glassfish.jaxb:jaxb-runtime:jar:2.3.0-b170127.1453 -> org.glassfish.jaxb:jaxb-core:jar:2.3.0-b170127.1453 -> javax.xml.bind:jaxb-api:jar:2.3.0-b161121.1438 ...

The only repository i could find that has this specific build is https://maven.java.net/#nexus-search;gav~javax.xml.bind~jaxb-api~2.3.0-b161121.1438~~

But if you look in the following file you can see the error on retrieving the artifact from this repository: .m2\repository\javax\xml\bind\jaxb-api\2.3.0-b161121.1438\jaxb-api-2.3.0-b161121.1438.pom.lastUpdated

Which is for me (with maven 3.8.4): https\://maven.java.net/content/repositories/releases/.error= http\://0.0.0.0/.error=Could not transfer artifact javax.xml.bind\:jaxb-api\:pom\:2.3.0-b161121.1438 from/to maven-default-http-blocker (http\://0.0.0.0/)\: Blocked mirror for repositories\: [...]

This is because maven 3.8.x has started blocking HTTP repositories by default. You could unblock the HTTP repository as follows: How to disable maven blocking external HTTP repositories?

But i would advice you not to unblock unsafe (non HTTPS) repositories. This would need to be changed in the maven settings.xml, complicating the build process.

My preferred solution would be to add an exclusion to the pom.xml file to ignore this specific jaxb-runtime version.

        <dependency>
            <groupId>org.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>3.10.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.jaxb</groupId>
                    <artifactId>jaxb-runtime</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

If you then still need the jaxb-runtime for your project to compile or run, you could include any other compatible version by adding a new dependency to it in your own pom.xml. In this case you can also use dependency management instead of exclusions.

You can pick one here: https://search.maven.org/artifact/org.glassfish.jaxb/jaxb-runtime

Make sure it satisfies the ehcache requirements: <version>[2.2,3)</version>