quarkus-amazon-lambda fails with java.net.UnknownHostException

Created on 26 Jul 2019  Â·  8Comments  Â·  Source: quarkusio/quarkus

Describe the bug
quarkus-amazon-lambda basic project generates UnknownHostException: null

Expected behavior
Unit test runs without any problems. quarkus:dev mode starts without any problems.

Actual behavior
Unable to run unit tests or startup in quarkus:dev mode.

Listening for transport dt_socket at address: 5005
2019-07-26 22:17:10,335 INFO  [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation
2019-07-26 22:17:10,940 INFO  [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 605ms
2019-07-26 22:17:11,130 INFO  [io.quarkus] (main) Quarkus 0.19.1 started in 0.885s. 
2019-07-26 22:17:11,132 INFO  [io.quarkus] (main) Installed features: [cdi, smallrye-rest-client]
2019-07-26 22:17:11,175 ERROR [io.qua.ama.lam.run.AmazonLambdaRecorder] (Lambda Thread) Failed to run lambda: java.net.UnknownHostException: null
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1963)
        at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1958)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1957)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1525)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
        at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder$2.run(AmazonLambdaRecorder.java:64)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.net.UnknownHostException: null
        at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:220)
        at java.base/java.net.Socket.connect(Socket.java:591)
        at java.base/java.net.Socket.connect(Socket.java:540)
        at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)
        at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
        at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569)
        at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
        at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:341)
        at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:362)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1242)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1181)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1075)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1009)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1581)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3084)
        at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder$2.run(AmazonLambdaRecorder.java:61)
        ... 1 more

2019-07-26 22:17:11,178 ERROR [io.qua.ama.lam.run.AmazonLambdaRecorder] (Lambda Thread) Error running lambda: java.net.UnknownHostException: null

To Reproduce
Steps to reproduce the behavior:

  1. git clone [email protected]:drissamri/quarkus-jvm-dev-bug.git
  2. mvn clean package or mvn compile quarkus:dev (same for mvn wrapper)

Environment (please complete the following information):

  • Output of uname -a or ver:
➜  ~ uname -a
Darwin localhost 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
  • Output of java -version:
➜  ~ java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
  • Quarkus version or git rev:
    0.19.1

Additional context
debug.log

kinbug triagout-of-date

Most helpful comment

So, it is impossible to run quarkus project in dev mode if it contains lambda function. Right?
How this can be solved? How can I run "mvnw compile quarkus:dev" when project contains lambda?

All 8 comments

that lambda code attempts to poll the AWS infrastructure for incoming requests before proxying off the request to your lambda code. That's the unknown host (null) that it's complaining about. Dev mode is not currently supported for this extension. You'll need to run something like SAM local to approximate this.

Alright, then this can be closed for now? Doing local validation with SAM Local works. Are there any plans to support this out of the box in the future?

I have a PR that rounds out the sam/local support. dev mode is slightly trickier...

Reopening as it seems @evanchooly has something in the works on the subject.

In my setup the unit tests using LambdaClientsucceed because the quarkus-test-amazon-lambda module is running an integrated Undertow server (LambdaResourceManager) to poll against.

However several UnknownHostExceptionsare thrown by AmazonLambdaRecorderat the end of the tests, when shutting down the Undertow server. Can this behaviour be fixed too? It seems to be a matter of timing when a test extension is stopped and when the AmazonLambdaRecorderThread is shut down.

So, it is impossible to run quarkus project in dev mode if it contains lambda function. Right?
How this can be solved? How can I run "mvnw compile quarkus:dev" when project contains lambda?

This issue/pullrequest has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This has been fixed in recent builds. 1.0.0-rc1 should be sufficient.

Was this page helpful?
0 / 5 - 0 ratings