I was playing a little bit with Vysper, embedding it into a Java EE web application in TomEE. Vysper is an alpha/beta version of a XMPP server based on Apache Mina that can be easily embedded into java applications. I could sucessfully instantiate a Vysper instance into a @Startup / @Singleton scoped bean. So far so good. It seems to work ok when I run it in a vanilla TomEE instance from inside eclipse.
But then I've remembered that Java EE applications should not use threads (see this answer at stack overflow - Why is spawning threads in Java EE container discouraged?). If I remember well, there are even wrappers for threads when someone need to run such a thing from inside a Java EE app.
I know that TomEE+ uses Quartz and ActiveMQ as backend to implement several Java EE services, but they're part of the container, not part of the web application.
I bet Mina and Vysper use threads internally, so I wonder it's not a good idea to embed Vysper directly into a Java EE web application in this context. Of course, I could just run the XMPP server as another component of the system, outside the container, which would also make more sense in a clustered deployment.
But supposing I am running in a standalone deployment (single TomEE), running an embedded Vysper into a Java EE web application could be harmful because it relies internally on threads? If it's not, why?
some things are forbidden but it is less and less strict and tomee (and most EE servers) doesn't impose it otherwise you can pretty much do nothing.
Only surprise you can get is to expect to be managed (security, CDI, ...) and since that's not container threads then you are not. If you accept this rule of the game then no issues.
PS: don't forget to shutdown correctly your threads