You can't do this kind of stuff (listening to sockets, createing your own threads) in ejbs.
You need to extend JBoss with your own service to do it:
See "extending jboss"
"How can I extend JBoss"
But what about if I use threads & sockets in the same VM, but outside of the ejb container? We use the bundled Tomcat. May I manage threads & sockets safely from a ServletContextListener (for examlpe)?
You could do this from a servlet. But writing an mbean service gives you full lifecycle control (start/stop) and manageability (through jmx).