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

WebSocket Encoder has to be explicitly registered for reflection #2745

Closed
michalszynkiewicz opened this issue Jun 6, 2019 · 0 comments · Fixed by #2749
Closed

WebSocket Encoder has to be explicitly registered for reflection #2745

michalszynkiewicz opened this issue Jun 6, 2019 · 0 comments · Fixed by #2749
Assignees
Labels
area/undertow kind/bug Something isn't working
Milestone

Comments

@michalszynkiewicz
Copy link
Member

Describe the bug
Using a custom encoder in the native mode fails with a failure on reflective instantiation.
A user needs to use @RegisterForReflection to make it work.

Expected behavior
I'd expect all encoders and decoders to be registered for reflection automatically

Actual behavior
Application fails to instantiate a custom encoder for a web socket server.

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/michalszynkiewicz/failing-email-service
  2. mvn clean package -Pnative
  3. go with your browser to http://localhost:8080

Environment (please complete the following information):

  • Output of uname -a or ver:
Linux t580 5.0.17-200.fc29.x86_64 #1 SMP Mon May 20 15:39:10 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version:
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
  • GraalVM version (if different from Java):
    RC15
  • Quarkus version or git rev: 0.16.0

Additional context
The stack trace:

UT026001: Unable to instantiate endpoint: java.lang.RuntimeException: java.lang.InstantiationException: Type `com.example.JsonEncoder` can not be instantiated reflectively as it does not have a no-parameter constructor or the no-parameter constructor has not been added explicitly to the native image.
        at io.quarkus.arc.runtime.ArcDeploymentTemplate$DefaultInstanceFactory.create(ArcDeploymentTemplate.java:152)
        at io.quarkus.undertow.runtime.UndertowDeploymentTemplate$6$1.createInstance(UndertowDeploymentTemplate.java:414)
        at io.undertow.websockets.jsr.EncodingFactory.createEncoding(EncodingFactory.java:126)
        at io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:121)
        at io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:165)
        at io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:385)
        at io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:232)
        at io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1279)
        at io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1563)
        at io.undertow.server.Connectors.terminateResponse(Connectors.java:147)
        at io.undertow.server.protocol.http.HttpTransferEncoding$3.handleEvent(HttpTransferEncoding.java:197)
        at io.undertow.server.protocol.http.HttpTransferEncoding$3.handleEvent(HttpTransferEncoding.java:195)
        at io.undertow.conduits.HeadStreamSinkConduit.exitFlush(HeadStreamSinkConduit.java:192)
        at io.undertow.conduits.HeadStreamSinkConduit.flush(HeadStreamSinkConduit.java:133)
        at org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
        at io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:119)
        at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
        at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:618)
        at io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:486)
        at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:575)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:351)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentTemplate$7$1$1.call(UndertowDeploymentTemplate.java:469)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1395)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:32)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:473)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
Caused by: java.lang.InstantiationException: Type `com.example.JsonEncoder` can not be instantiated reflectively as it does not have a no-parameter constructor or the no-parameter constructor has not been added explicitly to the native image.
        at java.lang.Class.newInstance(DynamicHub.java:740)
        at io.quarkus.arc.runtime.ArcDeploymentTemplate$DefaultInstanceFactory.create(ArcDeploymentTemplate.java:144)
        ... 41 more

@michalszynkiewicz michalszynkiewicz added the kind/bug Something isn't working label Jun 6, 2019
@michalszynkiewicz michalszynkiewicz self-assigned this Jun 6, 2019
michalszynkiewicz added a commit to michalszynkiewicz/quarkus that referenced this issue Jun 6, 2019
michalszynkiewicz added a commit to michalszynkiewicz/quarkus that referenced this issue Jun 7, 2019
michalszynkiewicz added a commit to michalszynkiewicz/quarkus that referenced this issue Jun 7, 2019
michalszynkiewicz added a commit to michalszynkiewicz/quarkus that referenced this issue Jun 7, 2019
mswiderski pushed a commit to mswiderski/quarkus that referenced this issue Jun 13, 2019
mswiderski pushed a commit to mswiderski/quarkus that referenced this issue Jun 13, 2019
@gsmet gsmet added this to the 0.17.0 milestone Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/undertow kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants