I have a standalone java project which is basically a Snmp trap listener. this application will keep listening in a port. currently this app will be started by calling main method.
how to deploy this project in Jboss. whenever jboss server is started this application should also started and keep listening in a port.
Sounds like you want to convert this app into a service. Exactly how to do this depends on the version of Boss AS. For 6.x and earlier you would convert it into an MBean. Not sure what the corresponding thing would be in 7.x.
Peter Johnson wrote:Not sure what the corresponding thing would be in 7.x.
AS 7.x supports MBeans too although the xsd for -service.xml files has changed slightly (some advanced features have been removed and no longer supported).
In EE6 you'll want to look at @Startup and @Singleton but remember that
Why can an enterprise bean not listen to or accept connections on a socket?
Because if an enterprise bean is listening on a socket, it can't be passivated -- it must always be available. Enterprise beans can be network socket clients, and so they can use other network resources (including other enterprise bean servers) to do their jobs. Just as with a database connection, don't hang on to open client sockets across method calls; instead, open them, communicate through the socket, and close it before returning from the method.
Of course you could use container specific strategies to turn off passivation and probably get it to work but the question here is what is the motivation for deploying this into an EJB container?