Skip to content
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

App that depends on Tomcat and on Jetty's websocket-server module fails to start with IllegalStateException: WebSocketComponents has not been created #38181

Closed
bukajsytlos opened this issue Nov 2, 2023 · 4 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@bukajsytlos
Copy link

bukajsytlos commented Nov 2, 2023

Spring boot 3.1.5
Seems there is still some issues with websocket autoconfiguration similar to #37660 .
Suggested workaround to disable websocket autoconfig works

2023-11-02T10:16:24.603+01:00 ERROR 3257818 --- [    Test worker] o.a.c.c.C.[Tomcat].[localhost].[/]       : Exception starting filter [org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter]

java.lang.IllegalStateException: WebSocketComponents has not been created
	at org.eclipse.jetty.websocket.core.server.WebSocketServerComponents.getWebSocketComponents(WebSocketServerComponents.java:131)
	at org.eclipse.jetty.websocket.core.server.WebSocketMappings.ensureMappings(WebSocketMappings.java:68)
	at org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter.init(WebSocketUpgradeFilter.java:182)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:263)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:102)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4271)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4886)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:845)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:240)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:917)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:488)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)
	```
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 2, 2023
@wilkinsona
Copy link
Member

Judging by the stack trace, you appear to be trying to use Jetty's WebSocketUpgradeFilter with Tomcat. This isn't supported. It may be that WebSocketServletAutoConfiguration is registering the filter but that would require Jetty's web socket-server module to be on the classpath at the same time as Tomcat. Can you please provide a minimal sample that reproduces the problem?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Nov 2, 2023
@bukajsytlos
Copy link
Author

This happens just by upgrading from 3.1.3 to 3.1.5 FAForever/faf-java-api#787

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 2, 2023
@wilkinsona
Copy link
Member

wilkinsona commented Nov 2, 2023

There are dependencies on both Tomcat (through spring-boot-starter-web) and Jetty (through spring-boot-starter-jetty). That's rather unusual but, as I suspected, it is the cause of the problem. We can address that in Spring Boot, but you may want to tidy up your dependencies as I doubt that both are needed.

@wilkinsona wilkinsona changed the title java.lang.IllegalStateException: WebSocketComponents has not been created Add fails to start with java.lang.IllegalStateException: WebSocketComponents has not been created when it depends on Tomcat and Jetty's websocket-server module Nov 2, 2023
@wilkinsona wilkinsona changed the title Add fails to start with java.lang.IllegalStateException: WebSocketComponents has not been created when it depends on Tomcat and Jetty's websocket-server module App that depends on Tomcat and Jetty's websocket-server module fails to start with java.lang.IllegalStateException: WebSocketComponents has not been created Nov 2, 2023
@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Nov 2, 2023
@wilkinsona wilkinsona added this to the 3.1.x milestone Nov 2, 2023
@wilkinsona wilkinsona changed the title App that depends on Tomcat and Jetty's websocket-server module fails to start with java.lang.IllegalStateException: WebSocketComponents has not been created App that depends on Tomcat and on Jetty's websocket-server module fails to start with java.lang.IllegalStateException: WebSocketComponents has not been created Nov 2, 2023
@bukajsytlos
Copy link
Author

bukajsytlos commented Nov 2, 2023

Thanks "moved" to tomcat.
We had

configurations {
  compile.exclude module: "spring-boot-starter-tomcat"

apparently no longer works (if ever) and with correct exclusion, we run into #33044

@philwebb philwebb changed the title App that depends on Tomcat and on Jetty's websocket-server module fails to start with java.lang.IllegalStateException: WebSocketComponents has not been created App that depends on Tomcat and on Jetty's websocket-server module fails to start with IllegalStateException: WebSocketComponents has not been created Nov 6, 2023
@wilkinsona wilkinsona self-assigned this Nov 9, 2023
@wilkinsona wilkinsona modified the milestones: 3.1.x, 3.1.6 Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants