-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
NPE Cannot invoke "org.eclipse.jetty.server.Request.getSession(boolean)" because the return value of "org.eclipse.jetty.ee10.servlet.ServletApiRequest.getRequest()" is null #11809
Comments
@donniexyz I would not try to access HTTP objects from within a WebSocket endpoint. There are other APIs that allow you to access the upgrade request and response before I'm referring to |
Also @donniexyz you may be interested in the upcoming servlet 6.1 feature that allows for access to a |
It already use the
|
Currently it does feels like chicken and egg problem, which one supposed to come first, websocket or request or session. And thanks for pointing that out, Accessor seems the right answer. However the code above works on Jetty 9, and initially I thought we can just return |
@donniexyz your You should either copy the values you need out of the HTTP comes before WebSocket. If you need to access HTTP request headers, you can copy those you need into a |
I see. Okay, now I copy the to be used variables into user properties on Thank you @sbordet @janbartel |
Jetty version(s)
12.0.9
Jetty Environment
ee10
Java version/vendor
(use: java -version)
java 21.0.1 2023-10-17 LTS Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29) Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)
OS type/version
Microsoft Windows [Version 10.0.22631.3593]
Description
Jetty-12 embedded with websocket, every 30 seconds logged this error:
Codes that triggers the error:
How to reproduce?
Most probably this is the sequence of the events leads to this situation:
The text was updated successfully, but these errors were encountered: