In JBoss, how is the sequence of the deployment phase? What is the order of object being instantiated and available to use? Considering an enterprise application (*.ear), inspecting all deployment log (server.log) the deployment phase looks like:
- All libs are deployed - .class files are loaded and available;
 - All *.jar modules are deployed - .class files are loaded and available;
 - If some *.jar is an EJB Jar, through the configuration files (Ex. ejb-jar.xml) or annotations, the JNDI tree is created;
 - If some *.jar has a persistence.xml file configuration, all entity and link to datasources are loaded;
 - All *.war modules start the deploy phase;
 - Through configuration files (web.xml), listeners and context-root are loaded and eventually security aspects.
 - Ear deployed successful.
 
Questions:
- What about the resource adapters modules, the PersistenceContext and the EJB Pool?
 - When a persistence.xml is found, does a connection to the data-source and so to the DB pool start?
 - Since the datasource (DB) is configured in the 
standalone.xmlordomain.xml, when happens the first connection to the DB pool? When I inject the PersistenceContext and use the EntityManager? - When the EJB pool is loaded and available to use?
 - Is correct to say that during the EJB jar deploy, the JNDI tree is created and then available?
 - When an EJB is discovered, it's loaded inside the pool (as reference to inject/lookup)?
 
When a .war module is deployed and ready, even if the full deploy of the .ear is not completed yet, possibly servlet or listener are started from the container.
- What happens if some of this objects (listener, servlet) try to use EJBs or PersistenceContext or other objects? Are those objects available?
 - Is it possible to have deadlock problem and hang the deployment thread/phase?