-
Notifications
You must be signed in to change notification settings - Fork 41.2k
WebSocket auto-configuration throws a CNFE with Jetty 10 #26847
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
Comments
Thanks Christophe, I've reproduced the problem. |
Workaround for the time being is to exclude the auto-configuration, e.g.: @SpringBootApplication(exclude = WebSocketServletAutoConfiguration.class) |
Our starter has a direct dependency on A sample project above means that we still bring
|
I've updated the release notes to reflect the current situation. Rather than excluding the WebSocket auto-configuration, I'd recommend excluding the unwanted Jetty 9-specific dependencies instead. This avoids having Jetty modules from two different versions on the classpath. |
To get WebSockets going with Jetty 10 two additional dependencies are needed:
You also need to add a class JettyWebSocketServletWebServerCustomizer implements WebServerFactoryCustomizer<JettyServletWebServerFactory>, Ordered {
@Override
public void customize(JettyServletWebServerFactory factory) {
factory.addConfigurations(new AbstractConfiguration() {
@Override
public void configure(WebAppContext context) throws Exception {
Context servletContext = context.getServletContext();
JettyWebSocketServerContainer jettyContainer = JettyWebSocketServerContainer.getContainer(servletContext);
Server server = context.getServer();
if (jettyContainer == null) {
WebSocketServerComponents.ensureWebSocketComponents(server, servletContext);
JettyWebSocketServerContainer.ensureContainer(servletContext);
}
JavaxWebSocketServerContainer javaxContainer = JavaxWebSocketServerContainer.getContainer(servletContext);
if (javaxContainer == null) {
WebSocketServerComponents.ensureWebSocketComponents(server, servletContext);
WebSocketUpgradeFilter.ensureFilter(servletContext);
WebSocketMappings.ensureMappings(servletContext);
JavaxWebSocketServerContainer.ensureContainer(servletContext);
}
}
});
}
@Override
public int getOrder() {
return 0;
}
} We should be able to include the customiser (modified to use reflection) in the auto-configuration so that only the dependency juggling is necessary. |
Has this problem been fixed? I also found this problem in the new version. springboot 2.5.5 and jdk 17,jetty 10.0.6 |
@leozhang123 I am not sure I understand your question. This issue is closed in a milestone with additional tests, so yes we believe it is fixed. If you think you've found an issue, please create a separate issue with a small sample we can run ourselves. Thank you. |
When using Jetty version 10.0.0 up to 10.0.3 and Java 11 (openjdk 11.0.7 2020-04-14) Spring Boot 2.5.0 can't start.
It can be reproduced from https://start.spring.io/
Modify the pom.xml as per Spring Boot 2.5.documentation
It ends up in the following stacktrace :
2021-06-10 08:41:04.659 ERROR 850316 --- [ main] o.s.boot.SpringApplication : Application run failed
The text was updated successfully, but these errors were encountered: