quarkus-maven-plugin:create : Maven Wrapper installation fails with "SocketException: Connection reset", probably because of proxy

Created on 25 Apr 2019  路  17Comments  路  Source: quarkusio/quarkus

mvn io.quarkus:quarkus-maven-plugin:0.14.0:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=getting-started \
    -DclassName="org.acme.quickstart.GreetingResource" \
    -Dpath="/hello"

yields:

[INFO] --- quarkus-maven-plugin:0.14.0:create (default-cli) @ standalone-pom ---
Creating a new project in C:\Develop\_dev\quarkus\.
Configuration file created in src/main/resources/META-INF/application.properties
Downloading from releases: https://artifacts.somedomain.de/artifactory/prj-ccs-build-release/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.pom
Downloaded from releases: https://artifacts.somedomain.de/artifactory/prj-ccs-build-release/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.pom (2.4 kB at 8.8 kB/s)
Downloading from releases: https://artifacts.somedomain.de/artifactory/prj-ccs-build-release/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar
Downloaded from releases: https://artifacts.somedomain.de/artifactory/prj-ccs-build-release/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar (51 kB at 685 kB/s)
[ERROR] Unable to install the Maven wrapper (./mvnw) in the project
org.apache.maven.plugin.MojoExecutionException: Error installing the Maven Wrapper.
    at io.takari.maven.plugins.WrapperMojo.execute (WrapperMojo.java:94)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:119)
    at io.quarkus.maven.CreateProjectMojo.createMavenWrapper (CreateProjectMojo.java:186)
    at io.quarkus.maven.CreateProjectMojo.execute (CreateProjectMojo.java:163)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    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.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:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    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: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read (SocketInputStream.java:210)
    at java.net.SocketInputStream.read (SocketInputStream.java:141)
    at sun.security.ssl.InputRecord.readFully (InputRecord.java:465)
    at sun.security.ssl.InputRecord.read (InputRecord.java:503)
    at sun.security.ssl.SSLSocketImpl.readRecord (SSLSocketImpl.java:975)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake (SSLSocketImpl.java:1367)
    at sun.security.ssl.SSLSocketImpl.startHandshake (SSLSocketImpl.java:1395)
    at sun.security.ssl.SSLSocketImpl.startHandshake (SSLSocketImpl.java:1379)
    at sun.net.www.protocol.https.HttpsClient.afterConnect (HttpsClient.java:559)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect (AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1564)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1492)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream (HttpsURLConnectionImpl.java:263)
    at org.apache.maven.wrapper.DefaultDownloader.downloadInternal (DefaultDownloader.java:90)
    at org.apache.maven.wrapper.DefaultDownloader.download (DefaultDownloader.java:76)
    at io.takari.maven.plugins.WrapperMojo.execute (WrapperMojo.java:78)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:119)
    at io.quarkus.maven.CreateProjectMojo.createMavenWrapper (CreateProjectMojo.java:186)
    at io.quarkus.maven.CreateProjectMojo.execute (CreateProjectMojo.java:163)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    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.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:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    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)
[INFO]
[INFO] ========================================================================================
[INFO] Your new application has been created in C:\Develop\_dev\quarkus\.
[INFO] Navigate into this directory and launch your application with mvn compile quarkus:dev
[INFO] Your application will be accessible on http://localhost:8080
[INFO] ========================================================================================
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.851 s
[INFO] Finished at: 2019-04-25T14:42:05+02:00
[INFO] ------------------------------------------------------------------------

This happens at work behind a proxy, but not at home (no proxy).

$ mvn -version
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T21:00:29+02:00)
Maven home: ...
Java version: 1.8.0_202, vendor: Oracle Corporation, runtime: ...
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Proxy environment variables are set/valid. Proxy is also defined in settings.xml.
I even tried adding -Dhttp.proxyHost=... to MAVEN_OPTS.

A quick look into the proxy related issues of takari/maven-wrapper seems to suggest that quarkus needs to work around the maven-wrapper limitations or should at least document how to fix this manually.

aremaven kinbug

Most helpful comment

@famod,

I even tried adding -Dhttp.proxyHost=... to MAVEN_OPTS

This is the right thing to do, except that the wrapper mojo downloads from a HTTPS URL (https://repo.maven.apache.org/maven2), so you should (even) set the -Dhttps.proxyHost system property into your MAVEN_OPTS. I think that should get it working. In case you want to customize few more things (like the proxy port), more system properties for Java proxy configuration can be found here https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html

All 17 comments

This is related to this issue: https://github.com/takari/maven-wrapper/issues/16 .

@aloubyansky considering we get the proxy somehow for the bootstrap, I was wondering if we could push it to when we call the Maven wrapper to install it?

WrapperMojo already has access to the user Settings that includes proxy configs.

@geoand could you see if we could pass explicitly the proxy options when creating the wrapper, then?

I will, but I am out of "office" and will have very limited computer access for the next week or so. But I'll check as soon as possible.

Reading this from my phone, it looks like it should be possible to do some things. I'll be able to take a closer look next weekend.

I looked into this and unfortunately there is nothing we can do on our end.
Although the WrapperMojo does have access to the Maven Settings object (see here) and I verified all user settings are passed to the wrapper invocation (via the debugger), proxies however are never consulted by the wrapper - only mirrors (see here).

One workaround might be to set MVNW_REPOURL.

I can also create a patch for the maven wrapper project that we could then pick up here if someone explains to me what the proper way of handling proxies in Maven :P

I hope that #2617 fix your problem

@jycr thanks for the PR, but this issue won't be fixed I believe by it. This has to do with the maven wrapper that is added when creating a new project

@famod,

I even tried adding -Dhttp.proxyHost=... to MAVEN_OPTS

This is the right thing to do, except that the wrapper mojo downloads from a HTTPS URL (https://repo.maven.apache.org/maven2), so you should (even) set the -Dhttps.proxyHost system property into your MAVEN_OPTS. I think that should get it working. In case you want to customize few more things (like the proxy port), more system properties for Java proxy configuration can be found here https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html

@jaikiran so I was wondering if we could push them automatically to the Maven wrapper installation process if a proxy is set at the Maven level?

@jaikiran

so you should (even) set the -Dhttps.proxyHost system property into your MAVEN_OPTS.

Confirmed! Setting this and -Dhttps.proxyPort did it. Thanks!
Sometimes you just don't see the obvious solution...

A hint regardings proxy settings in the guide would be nice.

@gsmet

I was wondering if we could push them automatically to the Maven wrapper installation process if a proxy is set at the Maven level?

That would be very user friendly! I mean I do/did have the HTTPS_PROXY environment variable set properly and I do also have a https proxy set in my settings.xml.

@jaikiran

so you should (even) set the -Dhttps.proxyHost system property into your MAVEN_OPTS.

Confirmed! Setting this and -Dhttps.proxyPort did it. Thanks!
Sometimes you just don't see the obvious solution...

A hint regardings proxy settings in the guide would be nice.

@famod sure, this will be useful in the maven tooling guide. Would you like to take a stab at this? It will have to be added in this guide https://github.com/quarkusio/quarkus/blob/9eb5164f24a2c3bc6b4015bc4e399a7ef955704c/docs/src/main/asciidoc/maven-tooling.adoc

@jaikiran so I was wondering if we could push them automatically to the Maven wrapper installation process if a proxy is set at the Maven level?

That's a good idea. Over the weekend, I'll see if this can be done in a reliable way.

@jaikiran do you have plans for this issue ?

Hello @rsvoboda, I had forgotten about this. I'll spend some time on this. Thank you for checking.

rm -rf ~/.m2/repository/io/takari/maven-wrapper/0.5.6
#retry
mvn io.quarkus:quarkus-maven-plugin:1.4.1.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=getting-started \
    -DclassName="org.acme.getting.started.GreetingResource" \
    -Dpath="/hello"
#OK...
Was this page helpful?
0 / 5 - 0 ratings