Imagine you have a standard java web-app using plain servlets, or SpringMVC, or whatever. You also want (for whatever reason) a way to talk to the server not using HTTP - I'll use direct sockets as it's the easiest example I can think of.
Writing a web-app is easy, you have servlets acting as entrypoints. Writing a java app which monitors ports is also pretty easy. But what about one that does both? Is it allowed without hacking? And if it turns out we agree this is a Bad Idea, what's a better architecture? Note that one of the motivations behind this is performance... we could easily have two separate apps sharing a DB but prefer to avoid using the DB as a communication tool, when information could be cached in memory much more efficiently.