To start up customer java class or jar file when Java EE server starts. The solution usually is

1. Via WAR, servlet ; set the = 1 tag for servlet to provide intial invocation while the WAR is deployed.
Like this J2ee Start a class when application server starts

2. Depends on Java EE server setup.
For example, using weblogic startup and shutdown mechanism for EAR, In the weblogic-application.xml ; placed the following

//config xml


I used second approach, so everytime I redeployed the EAR application the shutdown class main method was executed and then startup class invoked.

3. Using JBoss MBean service

Custom JMX MBeans in JBoss


How can an MBean depend on a SessionBean?

Writing JBoss MBean Services