Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable reflection init of NioSocketChannel with native image #1722

Merged
merged 3 commits into from
May 5, 2020

Conversation

danielkec
Copy link
Contributor

@danielkec danielkec commented May 4, 2020

To avoid error with native image:

Caused by: java.lang.IllegalArgumentException: Class NioSocketChannel does not have a public non-arg constructor
	at io.netty.channel.ReflectiveChannelFactory.<init>(ReflectiveChannelFactory.java:36)
	at io.netty.bootstrap.AbstractBootstrap.channel(AbstractBootstrap.java:104)
	at io.helidon.webclient.WebClientRequestBuilderImpl.lambda$invoke$7(WebClientRequestBuilderImpl.java:417)
	at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1106)
	at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235)
	at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:143)
	at io.helidon.webclient.WebClientRequestBuilderImpl.invoke(WebClientRequestBuilderImpl.java:395)
	at io.helidon.webclient.WebClientRequestBuilderImpl.lambda$submit$4(WebClientRequestBuilderImpl.java:318)
	at io.helidon.common.context.Contexts.runInContext(Contexts.java:118)
	at io.helidon.webclient.WebClientRequestBuilderImpl.submit(WebClientRequestBuilderImpl.java:318)
	at io.helidon.webclient.WebClientRequestBuilderImpl.submit(WebClientRequestBuilderImpl.java:328)
	at io.helidon.examples.webclient.standalone.ClientMain.performPutMethod(ClientMain.java:120)
	at io.helidon.examples.webclient.standalone.ClientMain.main(ClientMain.java:105)
	... 39 more
Caused by: java.lang.NoSuchMethodException: io.netty.channel.socket.nio.NioSocketChannel.<init>()
	at java.lang.Class.getConstructor0(DynamicHub.java:3349)
	at java.lang.Class.getConstructor(DynamicHub.java:2151)
	at io.netty.channel.ReflectiveChannelFactory.<init>(ReflectiveChannelFactory.java:34)
	... 51 more

Tested in https://github.com/danielkec/helidon/tree/native-webclient-test

helidon/examples/webclient/standalone$ mvn clean package -DskipTests -Pnative-image
helidon/examples/webclient/standalone$ sudo ./target/helidon-examples-webclient-standalone 

Then call GET at: WEB server is up! http://localhost:41549/greet/test

⚠️ sudo is needed because native image is using different tmp folder, see oracle/graal/issues/1754:

Path tempPath = Files.createTempFile("helidon-large", ".tmp");
System.out.println("TEMP FILE>"+tempPath.toAbsolutePath().toString());
// ---- java -jar ---- 
TEMP FILE>/tmp/helidon-large7670469747246904903.tmp
// ---- native image ----
TEMP FILE>/var/tmp/helidon-large7964339000716791151.tmp

Signed-off-by: Daniel Kec daniel.kec@oracle.com

Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
@danielkec danielkec added this to the 2.0.0 milestone May 4, 2020
@danielkec danielkec self-assigned this May 4, 2020
@tomas-langer tomas-langer mentioned this pull request May 4, 2020
13 tasks
Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
@danielkec danielkec merged commit d93910e into helidon-io:master May 5, 2020
@danielkec danielkec deleted the native-webclient branch May 5, 2020 19:56
absurdfarce added a commit to apache/cassandra-java-driver that referenced this pull request Jul 23, 2021
…thers as well. These were likely required in previous versions of""

This reverts commit 3cdf5fe.

Hmmm, a revert of a revert.. those are always tasty.

Original revert was motivated by the appearance of helidon-io/helidon#1722 in the Helidon test case.  Thing is
this can't be reproduced in non-Helidon contexts with the same GraalVM version.  And it's definitely the case that a no-arg
constructor is present (see
https://github.com/netty/netty/blob/netty-4.1.60.Final/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java).
So... this looks to be something unique to Helidon.
adutra pushed a commit to apache/cassandra-java-driver that referenced this pull request Jul 29, 2021
…thers as well. These were likely required in previous versions of""

This reverts commit 3cdf5fe.

Hmmm, a revert of a revert.. those are always tasty.

Original revert was motivated by the appearance of helidon-io/helidon#1722 in the Helidon test case.  Thing is
this can't be reproduced in non-Helidon contexts with the same GraalVM version.  And it's definitely the case that a no-arg
constructor is present (see
https://github.com/netty/netty/blob/netty-4.1.60.Final/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java).
So... this looks to be something unique to Helidon.
adutra pushed a commit to apache/cassandra-java-driver that referenced this pull request Jul 29, 2021
…thers as well. These were likely required in previous versions of""

This reverts commit 3cdf5fe.

Hmmm, a revert of a revert.. those are always tasty.

Original revert was motivated by the appearance of helidon-io/helidon#1722 in the Helidon test case.  Thing is
this can't be reproduced in non-Helidon contexts with the same GraalVM version.  And it's definitely the case that a no-arg
constructor is present (see
https://github.com/netty/netty/blob/netty-4.1.60.Final/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java).
So... this looks to be something unique to Helidon.
adutra pushed a commit to apache/cassandra-java-driver that referenced this pull request Jul 30, 2021
…thers as well. These were likely required in previous versions of""

This reverts commit 3cdf5fe.

Hmmm, a revert of a revert.. those are always tasty.

Original revert was motivated by the appearance of helidon-io/helidon#1722 in the Helidon test case.  Thing is
this can't be reproduced in non-Helidon contexts with the same GraalVM version.  And it's definitely the case that a no-arg
constructor is present (see
https://github.com/netty/netty/blob/netty-4.1.60.Final/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java).
So... this looks to be something unique to Helidon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants