JBoss AS has plenty of services available ready for use. However sometimes you might have the need to start a certain service after that your deployments units are available. Let's see how we can choose to deploy a service after your applications.



A typical use case would be that the EJB Timer service, which is configured in the server deploy directory with the ejb3-timer-service.xml.
A tutorial about the EJB3 Timer service is available here

Supposing you want your Timer service to be started after that your applications (a Web application and an EJB application) are deployed as shown here:

jboss as service mbean depends

All you have to do is adding a <depends> attribute to the EJB3TimerService MBean. Open the ejb3-timer-service.xml. This file already contains some dependancies on other services, we will add here our deployment dependency:
    <mbean code="org.jboss.ejb3.timerservice.quartz.jmx.EJB3TimerService" name="jboss.ejb:service=EJB3TimerService">
        <depends optional-attribute-name="DataSource">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
    <!-- WEB dependency -->
    <!-- EJB dependency -->
        <attribute name="Properties">
                 <!-- commented for brevity -->
As you can see, adding a dependency for a Web application is quite easy, you have just to add the WebContext name of the application. Dependency of an EJB application is also easy, you have just to state some additional information like the EJB Class name and the Service type (EJB3) as it falls in the generic jboss.j2ee tree. 

Related articles available on mastertheboss.com

How to configure JBoss to disable hot deployment ?

On JBoss AS 7 and WildFly the default rule is that archived appli

How do I make sure my MBean is deployed after my EJB ?

  If your MBean is dependant on another resource, supposing cont

How do I change the default lib directory in an ear file?

  Supposing you have an Enterprise application which has been pa

How to let JBoss deploy an application after other apps?

  If you are running JBoss AS 7 or WildFly check the following t

How to deploy an application temporarly with JBoss ?

One way to do it, is using the jboss.system:service=MainDeployer

How to add a custom JBoss archive in an Ear ?

JBoss custom archives (like .sar or .har) are not recognized by t