Is there any elegant way how to refuse incoming websocket connections when stopping tomcat in contextDestroyed?
Thanx in advance.
The general idea is that when Tomcat shutdown signal is received, all existing requests are finished to be served but no other new requests are allowed in. In a discussion about this, Mark Thomas (Tomcat developer) mentioned that there might be a slight bug prior to version 7.0.12 where connector was throwing an exception when shutting down.
You might also want to look at this diagram.
Above said, Tomcat should behave exactly as you wish, unless you have special requirements. But you need to explain in more details what you expect and what is actually happening.