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

[Tomcat 9.0.31] Missing WebSocket ServerContainer #900

Closed
boris-petrov opened this issue Feb 14, 2020 · 6 comments
Closed

[Tomcat 9.0.31] Missing WebSocket ServerContainer #900

boris-petrov opened this issue Feb 14, 2020 · 6 comments

Comments

@boris-petrov
Copy link

After updating Tomcat from 9.0.30 to 9.0.31 our integration tests don't want to even start due to:

FAILED org.cometd.server.BayeuxServerImpl@1ec3f0e5: java.lang.IllegalArgumentException: Missing WebSocket ServerContainer
java.lang.IllegalArgumentException: Missing WebSocket ServerContainer
        at org.cometd.websocket.server.WebSocketTransport.init(WebSocketTransport.java:72)
        at org.cometd.server.BayeuxServerImpl.initializeServerTransports(BayeuxServerImpl.java:255)
        at org.cometd.server.BayeuxServerImpl.doStart(BayeuxServerImpl.java:135)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.cometd.server.CometDServlet.init(CometDServlet.java:64)
        at org.cometd.annotation.AnnotationCometDServlet.init(AnnotationCometDServlet.java:52)
        at javax.servlet.GenericServlet.init(GenericServlet.java:158)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1134)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4871)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5180)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
        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:140)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
        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:140)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:467)
        ...

I'm not sure whether this is a Tomcat issue or a CometD one or I'm doing something wrong but it was working before... how do I begin debugging this? I have these dependencies (among others):

integrationTestRuntimeOnly "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcatVersion"
integrationTestRuntimeOnly "org.cometd.java:cometd-java-server:$cometDVersion"
integrationTestRuntimeOnly "org.cometd.java:cometd-java-websocket-javax-server:$cometDVersion"

CometD version is 3.1.12.

@sbordet
Copy link
Member

sbordet commented Feb 17, 2020

@boris-petrov the place where this exception is thrown is here.

This is the JSR 356 standard way to obtain the WebSocket ServerContainer, so Tomcat must expose it as per specification.

I don't know why it was working before, but this code in CometD did not change because it's the standard and only way of accessing the WebSocket container.

Have you asked the Tomcat project?

@boris-petrov
Copy link
Author

boris-petrov commented Feb 17, 2020

@sbordet - I haven't asked there yet, no. So this cannot be an application-configuration issue but is rather a Tomcat problem for sure? Or it's possible I'm not doing something right?

@sbordet
Copy link
Member

sbordet commented Feb 17, 2020

@boris-petrov I don't know. I don't think it's a CometD issue.

Could be your application configuration, or how you configure Tomcat, or how you package your webapp.

If it was Jetty, I would say that you have either misconfigured your JETTY_BASE if you use Jetty standalone server, or you have forgot some jar in the classpath if you use Jetty embedded.

Try to enable DEBUG logging for Tomcat, and you should see if there are errors.

@boris-petrov
Copy link
Author

@sbordet - I've opened an issue in Tomcat's Bugzilla and I've given them a reproduction project so I hope they can fix it. I'll close this issue for now and will follow up if they think the problem is not there but in CometD.

Thanks for the support!

@sbordet
Copy link
Member

sbordet commented Feb 24, 2020

@boris-petrov are you configuring Tomcat with HTTP/2 only (no HTTP/1.1) and WebSocket?
Chances are that Tomcat does not support WebSocket over HTTP/2 and so it won't expose the ServerContainer.

@boris-petrov
Copy link
Author

Well, I do have this line:

tomcat.connector.add_upgrade_protocol(Http2Protocol.new)

But even commenting it out doesn't help. Also, I didn't change any code between the Tomcat version update so this was working before. I think this code doesn't remove the default HTTP/1.1 connector. Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants