-
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
Class loading broken for WebSocketClient used inside webapp #6287
Comments
Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
…ntClassLoading Issue #6287 - fix classloading for WebSocketClient in webapp
Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
Hello @sbordet / @lachlan-roberts, good day to you! I guess I'm facing this problem. More details here. Could this be confirmed? |
@Deepak-D from reading the description it doesn't seem to be the same issue. This issue is only relating to the use of If not would it be possible to attach a simple reproducer where the |
Hello @lachlan-roberts , thanks for your feedback.. Here is my case! I have WebSocket ClientEndPoint will look like below
WebSocket ServerEndPoint will look like below
This client and server is designed to work based on the publish/subscribe model using topics (Similar to mqtt). I have a interface in client.jar and this interface will be implemented inside webapp which uses this client.jar to handle data received from server endpoint for the subscription of each topic. interface in client.jar will look like below
Implementation inside webapp will look like below
I have list of topics and its dedicated class full name implementing the NotificationHandler interface inside webapp. On webapp startup, I'm establishing websocket connection to the server endpoint using client.jar which has client endpoint using the webapp's unigue client id to differentiate client's session on server side. Then, I'm doing topic subscription to the server and I will create class instance dedicated for that specific topic and persist inside client.jar in a HashMap. Whenever I receive subscription message from the server for the topic, I will get the instance from HashMap and call handle method of the NotificationHandler interface passing topic and data received. In this flow, when I try to get the class loader instance using Hope this helps! If not, I will try to prepare a reproducer. |
…tClassLoading Issue #6287 - fix classloading for WebSocketClient in webapp
Jetty version
9.4.x
Description
The fix for #5859 resolved the leaking of
ClassLoader
s, but now causes class loading issues in web applications, see for example: cometd/cometd#1037.A web application using the WebSocket client may trigger the creation of a thread, which before #5859 was inheriting the webapp
ClassLoader
as contextClassLoader
, but now the thread gets the serverClassLoader
as the contextClassLoader
.If the task at hand needs to load a class from the webapp (for example due to JSON parsing using
oej.util.Loader.loadClass()
, it was succeeding before #5859, but fails now.Obviously we want to keep the fix for #5859, but we need to explicitly set the context
ClassLoader
before calling webapp code (e.g. listeners, callbacks, etc.) in those components that are provided by the server, in particularWebSocketClient
.The text was updated successfully, but these errors were encountered: