views:

42

answers:

3

Hi, I have an EJB project communicating with a Swing client over RPC. I would like to know how to call EJB or utility class methods on the business logic at server startup.

Thanks.

A: 

Easiest way is to add a WAR with an application context listener. This listener has callbacks when the applications is started and stopped. It's a good area to place calls in to your back end logic when the application starts up or shuts down (server is stopped or app is undeployed).

EJB 3.1 is supposed to have better support for this, I don't know JBoss status on implementing 3.1. But I probably wouldn't upgrade just for this.

I should note that the WAR only works when bundled with the EJBs in an EAR, otherwise the WAR may start up before the EJBs are deployed.

Will Hartung
A: 

You could use a startup class for this (and put the startup class in the deploy.last subdirectory of deploy to get it run after other deployments are deployed).

Pascal Thivent
A: 

MBeans can be used to do some process at JBoss startup or can alternatively use servlet which can be loaded easily at startup according to your requirement.

Nayan Wadekar