Why does my maven dependency fetching fail with a connection reset when running `docker build`?

2k views Asked by At

I am trying to build a docker image of a maven project. When I run mvn dependency:go-offline in my project directory, the project builds successfully, but when I run the same command with docker build ., I get a connection reset

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.335 s
[INFO] Finished at: 2020-12-17T16:26:23Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:resolve-plugins (resolve-plugins) on project aida: Nested:: Could not transfer artifact org.apache.maven:maven-toolchain:jar:2.2.1 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.2.1/maven-toolchain-2.2.1.jar
[ERROR]   org.apache.maven:maven-toolchain:jar:2.2.1
[ERROR] 
[ERROR] from the specified remote repositories:
[ERROR]   central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false): Connection reset
[ERROR] -> [Help 1] 

It fails on a different remote dependency every time. The first time it failed to get org.apache.maven:maven-toolchain:jar:2.2.1. The second time it failed to get org.codehaus.plexus:plexus-interpolation:jar:1.11. As shown by the links above, both repositories exist on the central repository. Every run seems to throw a similar error for a different package.

The error help page for Help 1 has a few possible causes, but I couldn't identify one that would only be true for docker environments. Network issues like proxies should equally apply to the host machine.

MCVE

Dockerfile

FROM maven:3.6.3-jdk-11 as target

WORKDIR /test
COPY ./pom.xml /test

RUN mvn dependency:go-offline
# RUN mvn -e dependency:go-offline # Alternate command for full stack trace

pom.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.4</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>29.0-android</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.11</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <version>2.2</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Full error log output with docker build . Without verbose error trace mvn -e flag

Sending build context to Docker daemon  277.5kB
Step 1/4 : FROM maven:3.6.3-jdk-11 as target
 ---> 25b8de0642c0
Step 2/4 : WORKDIR /test
 ---> Using cache
 ---> c51be64ec620
Step 3/4 : COPY ./pom.xml /test
 ---> 5f96b065e0ce
Step 4/4 : RUN mvn dependency:go-offline
 ---> Running in 8eda9d2a4756
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.8.0/maven-compiler-plugin-3.8.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.8.0/maven-compiler-plugin-3.8.0.pom (12 kB at 55 kB/s)
(... # Many more lines like this)
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.jar (153 kB at 2.9 MB/s)
[INFO] 
[INFO] -----------------------------< test:test >------------------------------
[INFO] Building test 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> maven-dependency-plugin:2.8:go-offline (default-cli) > :resolve-plugins @ test >>>
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:resolve-plugins (resolve-plugins) @ test ---
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.0.9/maven-artifact-2.0.9.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.0.9/maven-artifact-2.0.9.pom (1.6 kB at 202 kB/s)
(... # Many more lines like this)
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/9/commons-parent-9.pom (22 kB at 2.7 MB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.223 s
[INFO] Finished at: 2020-12-17T22:46:18Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:resolve-plugins (resolve-plugins) on project test: Execution resolve-plugins of goal org.apache.maven.plugins:maven-dependency-plugin:2.8:resolve-plugins failed: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 -> org.apache.maven:maven-project:jar:2.0.9 -> org.apache.maven:maven-settings:jar:2.0.9 -> org.apache.maven:maven-model:jar:2.0.9: Failed to read artifact descriptor for org.apache.maven:maven-model:jar:2.0.9: Could not transfer artifact org.apache.maven:maven-model:pom:2.0.9 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.0.9/maven-model-2.0.9.pom: Connection reset -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
The command '/bin/sh -c mvn dependency:go-offline' returned a non-zero code: 1

The full stack trace from with docker build . with mvn -e flag

GET request of: commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar from central failed
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution resolve-plugins of goal org.apache.maven.plugins:maven-dependency-plugin:2.8:resolve-plugins failed: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: The following artifacts could not be resolved: commons-beanutils:commons-beanutils:jar:1.7.0, commons-digester:commons-digester:jar:1.6: Could not transfer artifact commons-beanutils:commons-beanutils:jar:1.7.0 from/to central (https://repo.maven.apache.org/maven2): GET request of: commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar from central failed
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:109)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: The following artifacts could not be resolved: commons-beanutils:commons-beanutils:jar:1.7.0, commons-digester:commons-digester:jar:1.6: Could not transfer artifact commons-beanutils:commons-beanutils:jar:1.7.0 from/to central (https://repo.maven.apache.org/maven2): GET request of: commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar from central failed
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolveInternal (DefaultPluginDependenciesResolver.java:221)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:152)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.createPluginRealm (DefaultMavenPluginManager.java:404)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.setupPluginRealm (DefaultMavenPluginManager.java:374)
    at org.apache.maven.plugin.DefaultBuildPluginManager.getPluginRealm (DefaultBuildPluginManager.java:234)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:105)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: commons-beanutils:commons-beanutils:jar:1.7.0, commons-digester:commons-digester:jar:1.6: Could not transfer artifact commons-beanutils:commons-beanutils:jar:1.7.0 from/to central (https://repo.maven.apache.org/maven2): GET request of: commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar from central failed
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:424)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:340)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolveInternal (DefaultPluginDependenciesResolver.java:213)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:152)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.createPluginRealm (DefaultMavenPluginManager.java:404)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.setupPluginRealm (DefaultMavenPluginManager.java:374)
    at org.apache.maven.plugin.DefaultBuildPluginManager.getPluginRealm (DefaultBuildPluginManager.java:234)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:105)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact commons-beanutils:commons-beanutils:jar:1.7.0 from/to central (https://repo.maven.apache.org/maven2): GET request of: commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar from central failed
    at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed (ArtifactTransportListener.java:52)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:369)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
    at java.lang.Thread.run (Thread.java:834)
Caused by: org.apache.maven.wagon.TransferFailedException: GET request of: commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar from central failed
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:412)
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:338)
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:307)
    at org.apache.maven.wagon.StreamWagon.getIfNewer (StreamWagon.java:97)
    at org.apache.maven.wagon.StreamWagon.get (StreamWagon.java:61)
    at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run (WagonTransporter.java:567)
    at org.eclipse.aether.transport.wagon.WagonTransporter.execute (WagonTransporter.java:435)
    at org.eclipse.aether.transport.wagon.WagonTransporter.get (WagonTransporter.java:412)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask (BasicRepositoryConnector.java:457)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:364)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
    at java.lang.Thread.run (Thread.java:834)
Caused by: javax.net.ssl.SSLException: Connection reset
    at sun.security.ssl.Alert.createSSLException (Alert.java:127)
    at sun.security.ssl.TransportContext.fatal (TransportContext.java:350)
    at sun.security.ssl.TransportContext.fatal (TransportContext.java:293)
    at sun.security.ssl.TransportContext.fatal (TransportContext.java:288)
    at sun.security.ssl.SSLTransport.decode (SSLTransport.java:144)
    at sun.security.ssl.SSLSocketImpl.decode (SSLSocketImpl.java:1411)
    at sun.security.ssl.SSLSocketImpl.readApplicationRecord (SSLSocketImpl.java:1376)
    at sun.security.ssl.SSLSocketImpl$AppInputStream.read (SSLSocketImpl.java:963)
    at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionInputBufferImpl.streamRead (SessionInputBufferImpl.java:137)
    at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionInputBufferImpl.read (SessionInputBufferImpl.java:197)
    at org.apache.maven.wagon.providers.http.httpclient.impl.io.ContentLengthInputStream.read (ContentLengthInputStream.java:176)
    at org.apache.maven.wagon.providers.http.httpclient.conn.EofSensorInputStream.read (EofSensorInputStream.java:135)
    at java.nio.channels.Channels$ReadableByteChannelImpl.read (Channels.java:388)
    at org.apache.maven.wagon.AbstractWagon.transfer (AbstractWagon.java:597)
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:395)
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:338)
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:307)
    at org.apache.maven.wagon.StreamWagon.getIfNewer (StreamWagon.java:97)
    at org.apache.maven.wagon.StreamWagon.get (StreamWagon.java:61)
    at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run (WagonTransporter.java:567)
    at org.eclipse.aether.transport.wagon.WagonTransporter.execute (WagonTransporter.java:435)
    at org.eclipse.aether.transport.wagon.WagonTransporter.get (WagonTransporter.java:412)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask (BasicRepositoryConnector.java:457)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:364)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
    at java.lang.Thread.run (Thread.java:834)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read (SocketInputStream.java:186)
    at java.net.SocketInputStream.read (SocketInputStream.java:140)
    at sun.security.ssl.SSLSocketInputRecord.read (SSLSocketInputRecord.java:476)
    at sun.security.ssl.SSLSocketInputRecord.readFully (SSLSocketInputRecord.java:459)
    at sun.security.ssl.SSLSocketInputRecord.decodeInputRecord (SSLSocketInputRecord.java:243)
    at sun.security.ssl.SSLSocketInputRecord.decode (SSLSocketInputRecord.java:181)
    at sun.security.ssl.SSLTransport.decode (SSLTransport.java:110)
    at sun.security.ssl.SSLSocketImpl.decode (SSLSocketImpl.java:1411)
    at sun.security.ssl.SSLSocketImpl.readApplicationRecord (SSLSocketImpl.java:1376)
    at sun.security.ssl.SSLSocketImpl$AppInputStream.read (SSLSocketImpl.java:963)
    at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionInputBufferImpl.streamRead (SessionInputBufferImpl.java:137)
    at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionInputBufferImpl.read (SessionInputBufferImpl.java:197)
    at org.apache.maven.wagon.providers.http.httpclient.impl.io.ContentLengthInputStream.read (ContentLengthInputStream.java:176)
    at org.apache.maven.wagon.providers.http.httpclient.conn.EofSensorInputStream.read (EofSensorInputStream.java:135)
    at java.nio.channels.Channels$ReadableByteChannelImpl.read (Channels.java:388)
    at org.apache.maven.wagon.AbstractWagon.transfer (AbstractWagon.java:597)
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:395)
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:338)
    at org.apache.maven.wagon.AbstractWagon.getTransfer (AbstractWagon.java:307)
    at org.apache.maven.wagon.StreamWagon.getIfNewer (StreamWagon.java:97)
    at org.apache.maven.wagon.StreamWagon.get (StreamWagon.java:61)
    at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run (WagonTransporter.java:567)
    at org.eclipse.aether.transport.wagon.WagonTransporter.execute (WagonTransporter.java:435)
    at org.eclipse.aether.transport.wagon.WagonTransporter.get (WagonTransporter.java:412)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask (BasicRepositoryConnector.java:457)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:364)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
    at java.lang.Thread.run (Thread.java:834)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
The command '/bin/sh -c mvn -e dependency:go-offline' returned a non-zero code: 1

System information

  • Apache Maven 3.6.0
  • Docker version 20.10.1, build 831ebea
  • Java version: 11.0.9.1, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
  • Default locale: en_US, platform encoding: UTF-8
  • OS name: "linux", version: "4.15.0-126-generic", arch: "amd64", family: "unix"
1

There are 1 answers

0
Cecilia On

This solution is based on this excellent (and comprehensive) post, Fix a Random Network Connection Reset Issue in Docker/Kubernetes.

The Connection Reset is due to an INVALID TCP packet going across a firewall and the destination address not being rewritten to reflect the port that the Docker is listening on. To quote the article:

When the INVALID packet goes through the firewall, conntrack does not rewrite its destination address to the Pod’s IP address/port. Instead, the destination is the host’s IP address, with a port nobody is listening. A RST packet is sent back and causes the connection to be closed.

Since this rewrite step is only needed for the Docker, the running mvn dependency:go-offline on the host encounters no problems.

To fix the Docker issue, the author suggests adding a rule to drop INVALID packets to the host iptables. To add this rule, I used

sudo iptables -A INPUT -i eth0 -m state --state INVALID -j DROP

You may experience this issue on any host Docker machine that doesn't have dropping INVALID packets as a default in its iptables rules. The post author reproduced the connection reset on Ubuntu and Debian. Fedora/CentOs has the INVALID drop line in its default iptables rules, and so should not suffer from this problem.