Skip to content

Websockets next incompatible with undertow extension when using @SessionScoped #46548

@Malandril

Description

@Malandril

Describe the bug

When declaring a websocket next endpoint with @SessionScoped and the undertow extension is present quarkus fails with

jakarta.enterprise.context.ContextNotActiveException: SessionScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=foo.WebsocketController, id=lNM_wkJwmYkOEPs73Mdy8AVQkns]
        - @SessionScoped is not supported by default. However, a Quarkus extension implementing session context can be used to enable this functionality (such as Undertow extension).
        at io.quarkus.arc.impl.ClientProxies.notActive(ClientProxies.java:76)
        at io.quarkus.arc.impl.ClientProxies.getSingleContextDelegate(ClientProxies.java:32)
        at foo.WebsocketController_ClientProxy.arc$delegate(Unknown Source)
        at foo.WebsocketController_ClientProxy.open(Unknown Source)
        at foo.WebsocketController_WebSocketServerEndpoint.doOnOpen(Unknown Source)
        at io.quarkus.websockets.next.runtime.WebSocketEndpointBase$4.call(WebSocketEndpointBase.java:167)
        at io.quarkus.websockets.next.runtime.WebSocketEndpointBase$4.call(WebSocketEndpointBase.java:161)
        at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$4(ContextImpl.java:192)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:270)
        at io.vertx.core.impl.ContextImpl$1.execute(ContextImpl.java:221)
        at io.vertx.core.impl.WorkerTask.run(WorkerTask.java:56)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)

Expected behavior

Adding the Undertow extension should not make the websocket fail if it is @SessionScoped

Actual behavior

No response

How to Reproduce?

Simply having the undertow extension and websockets-next and the following is enough

@SessionScoped
@WebSocket(path = "/ws")
public class WebsocketController {
    @OnOpen
    void open(){
        Log.info("Connected");
    }
}

Reproducer

  1. Clone the reproducer https://github.com/Malandril/quarkus-bug-websocket-undertow
  2. run quarkus dev
  3. try to connect using websockets to ws://localhost:8080/ws

Output of uname -a or ver

linux

Output of java -version

21

Quarkus version or git rev

3.19.1

Build tool (ie. output of mvnw --version or gradlew --version)

gradle

Additional information

This happens since quarkus 3.18

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions