What type of bean, and why would you need to do that?
A relatively cross-server easy way would be to use a <load-on-startup> servlet (in the Web.xml ) which would call the bean in its init() method.
I'm not a Sun Server user, so there maybe a server-specific way to do that, that I'm not aware of.
Well; to describe more in detail: I'm building a integration server; where i build a Web portal, and have connected several EJB's that does the work of the different interfaces. (These are JMS connected beans)
What i need to build now is an application controlling the work queue/scheduling. For this purpose i need an application that auto starts with the application server, and checks for "new" work by example once a minute.
Regards,
janir
You could do that at the Web layer, and implement a ServletContextListener.
The class will then listen for application stratup and shutdown events, and the contextInitialized() method in particular will call your bean.
You'd of course mention the listener in your web.xml under <listener>.
Hi janir,
What karma-9 is suggesting is simply using the web container initialization event to call into an
EJB that will then create a periodic EJB timer.Unfortunately, there are no container-initialization
or automatic deployment initialization events in EJB, so the best you can do, portably, is to leverage
the web container events by packaging a simple .war along with the ejb-jar into an .ear.All the
servlet context listener needs to do is lookup (or inject) a reference to a stateless session bean that
defines a business method in which the EJB timer is created.Note that you should also check to
see if the timer has already been created before creating it since the EJB timers are persistent and
the web container initialization event happens every time the server is started.
We are planning to add better support for this use-case in the next version of the EJB spec.
--ken