-
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
IllegalAccessException when invoking WebSocket end point methods in Jetty 12 #11096
Comments
@unitydynamics you got the JPMS configuration the other way around. You need to grant At the same time, your module cannot tell to a Jetty module what it should read. Therefore, you need to start the JVM with Since your classes and methods are We need to improve the documentation, so I opened #11213. |
FTR, this is clarified in JEP 261, section "Increasing readability". |
Thank you @sbordet ! I've used Java since it's inception many decades ago and this is the first time I've run into a need for In a neat an tidy world I would love to see all of our module security parameters in |
I would be surprised if that works. |
minimal_repro2.zip Along a similar vein, it looks like Guice Aspect Oriented Programming uses a trick: dynamically creating a subclass of your class (and then calling the super implementation in that new subclass). Maybe Jetty could do this as well? |
I was about to write up an example of Jackson (which does everything--including method calls); but I think I know why these other libraries are working without So yes, we can put |
You may actually have hit a Jetty bug... Looking more closely, we have no problems when using annotations, but we do when using It seems a problem of the |
All right, this is the way it works. If you use Jetty WebSocket annotations, we use an "application" However, if you use I think that if we drop support for anonymous WebSocket endpoint classes, then we could use the "application" lookup for @lachlan-roberts thoughts? |
As a user/outside observer... I prefer the ability to implement the interface (rather than use the annotation). And I would like to avoid the |
Guess who asked to support anonymous classes? |
…t methods in Jetty 12 Changed `JettyWebSocketFrameHandlerFactory` to use an application MethodHandle.Lookup (rather than a server one) when creating listener metadata. This fixes the JPMS problem so that now JPMS applications do not need any additional configuration to invoke endpoints. The (acceptable) downside is that anonymous inner classes (that are not public) cannot be used as listener endpoints. This change affects core and EE10 WebSocket; EE9 and EE8 WebSocket have not been fixed (so they allow anonymous inner classes but are broken in JPMS). Renamed "connectLatch" fields to "openLatch" in test classes. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…t methods in Jetty 12 (#11229) Changed `JettyWebSocketFrameHandlerFactory` to use an application MethodHandle.Lookup (rather than a server one) when creating listener metadata. This fixes the JPMS problem so that now JPMS applications do not need any additional configuration to invoke endpoints. The (acceptable) downside is that anonymous inner classes (that are not public) cannot be used as listener endpoints. This change affects core and EE10 WebSocket; EE9 and EE8 WebSocket have not been fixed (so they allow anonymous inner classes but are broken in JPMS). Renamed "connectLatch" fields to "openLatch" in test classes. Signed-off-by: Simone Bordet <simone.bordet@gmail.com> Signed-off-by: Olivier Lamy <olamy@apache.org> Co-authored-by: Olivier Lamy <olamy@apache.org>
Jetty version(s)
Jetty 12.0.5
Jetty Environment
core
Java version/vendor
(use: java -version)
OpenJDK 21.0.1+12-29
OS type/version
Ubuntu
Description
When using modules in Java 21 (must have a module-info.java). Jetty fails to load the web socket endpoint you've provided:
This error happens even when your endpoint class is in a package that is exported / opened to all modules in module-info.java:
Same error in Java 17.
Here is the dependency section my pom.xml:
How to reproduce?
Minimal reproduction attached. This example code is a websocket client, but the error is identical when trying to start up a server for websockets using just the "core" libraries for Jetty 12. I'm hopeful that solving for one can lead to solving for both scenarios.
minimal_repro.zip
These are the two files:
TestWebSocketClient.java
TestWebSocketEndPoint.java
If you delete module-info.java in the minimal reproduction I've provided the example code works. In my large enterprise codebase I need to use modules and module security.
The text was updated successfully, but these errors were encountered: