How do I resolve Could not find artifact javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 in central (https://repo1.maven.org/maven2)?
Asked Answered
P

3

15

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?

Paleolith answered 5/5, 2022 at 13:29 Comment(3)
What is in the POM file?Dubois
Here's what I added for ehcache. I'm assuming it uses the artifact since I didn't have that error until I updated ehcache from the 2.1.x version. (can't get this to format correctly) ` <dependency> <groupId>org.ehcache</groupId> <artifactId>ehcache</artifactId> <version>3.10.0</version> </dependency> `Paleolith
I just dumped it from my local .m2 and rebuilt, and it added it back, but I still get the error. <grumble grumble grumble>Paleolith
T
14

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>

Thorman answered 7/5, 2022 at 8:11 Comment(3)
Thank you, worked for me. Created the dependency as specified. Also added jaxb-runtime version 2.3.8. I built my Maven project from the command line until I fixed the issue. Seems IntelliJ uses a cached version of the Maven pom.xml file sometimes when you edit it - it takes IntelliJ a second to load the latest Maven pom.xml when you use IntelliJ to build your project.Flimflam
@Flimflam yeah, IntelliJ needs to update your local project to match the pom file. You can check if any of these tips can help speed that up. If those are all already configured or known to you, then it can just be the processing time indeed.Thorman
Related github.com/gephi/gephi-plugins/issues/226Errant
A
1

While latest 3.10 version of ehcache is failing as for April 2024, the version 3.9 seems to be stable and builds ok on maven docker image maven:3-eclipse-temurin-17-alpine, and maven:3-eclipse-temurin:21-jre-alpine. Use this code in pom.xml:

                <dependency>
                        <groupId>org.ehcache</groupId>
                        <artifactId>ehcache</artifactId>
                        <version>3.9.11</version>
                        <!-- <classifier>jakarta</classifier> -->
                </dependency>

This is related to http protocol forbidden in current maven, but still in use on some old libraries.

Issue on github https://github.com/ehcache/ehcache3/issues/3215

Acro answered 3/4, 2024 at 2:33 Comment(1)
After a long absence I merely today followed most of the steps from this forum thread. And found related github.com/gephi/gephi-plugins/issues/226Errant
F
1

I found a way to determine the correct mirrors because maven gives all the information.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.6.1:go-offline (default-cli) on project ehache-test: org.eclipse.aether.resolution.DependencyResolutionException:
Failed to collect dependencies at org.ehcache:ehcache:jar:jakarta:3.10.8
-> 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: 
Failed to read artifact descriptor for javax.xml.bind:jaxb-api:jar:2.3.0-b161121.1438: 
The following artifacts could not be resolved: javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 (absent): 
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: 
    [releases.java.net (http://maven.java.net/content/repositories/releases/, default, releases+snapshots), 
    shapshots.java.net (http://maven.java.net/content/repositories/snapshots/, default, releases+snapshots), 
    jvnet-nexus-staging (http://maven.java.net/content/repositories/staging/, default, releases+snapshots), 
    netbeans (http://bits.netbeans.org/nexus/content/groups/netbeans, default, releases)] -> [Help 1]

For each http repository the error message give the repository id and the url of that repository.

releases.java.net (http://maven.java.net/content/repositories/releases/, default, releases+snapshots)

So the corresponding mirror you need to define is (and you can even use the https url instead of http)

<mirror>
  <id>releases.java.net-mirror</id>
  <name>releases.java.net Mirror</name>
  <url>https://maven.java.net/content/repositories/releases/</url>
  <mirrorOf>releases.java.net</mirrorOf>
</mirror>

In order to be able to use ehcache 3.10.8 I needed 4 mirrors in my settings.xml:

    <mirror>
        <id>releases.java.net-mirror</id>
        <name>releases.java.net Mirror</name>
        <url>https://maven.java.net/content/repositories/releases/</url>
        <mirrorOf>releases.java.net</mirrorOf>
    </mirror>
    <mirror>
        <id>shapshots.java.net-mirror</id>
        <name>shapshots.java.net Mirror</name>
        <url>https://maven.java.net/content/repositories/snapshots/</url>
        <mirrorOf>shapshots.java.net</mirrorOf>
    </mirror>
    <mirror>
        <id>jvnet-nexus-staging-mirror</id>
        <name>jvnet-nexus-staging Mirror</name>
        <url>https://maven.java.net/content/repositories/staging/</url>
        <mirrorOf>jvnet-nexus-staging</mirrorOf>
    </mirror>
    <mirror>
        <id>netbeans-mirror</id>
        <name>netbeans Mirror</name>
        <url>https://netbeans.apidesign.org/maven2/</url>
        <mirrorOf>netbeans</mirrorOf>
    </mirror>

The tricky part was the netbeans mirror, the url https://bits.netbeans.org/nexus/content/groups/netbeans has been decommissioned and the page about it is wrong https://netbeans.apache.org/about/oracle-transition.html instead of https://netbeans.apache.org/front/main/about/oracle-transition/

Factitive answered 4/9, 2024 at 9:20 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.