Basically, there was a ServletContextListener implementation which performs a look up to a Stateless Session Bean in its contextInitialized method. Nothing new, nothing different from what you've already seen...
public void contextInitialized(ServletContextEvent arg0) { try { Context ctx = new InitialContext(); Object o = ctx.lookup("java:app/my-ejb/MyBean!com.blogspot.brmachado.service.MyBeanLocal"); System.out.println(o); } catch(Exception e) { } }
I saw all application EJBs being deployed successfully in the log, as well as it's JNDI bindings but even so there were a javax.naming.NameNotFoundException in the contextInitialized method. In AS 4.x and 5.x the application was deployed fine, but why NameNotFoundException was being thrown in EAP 6?
Next step in the troubleshooting process was to verify in the console if the JNDI bind was really there, and it was. Then I create a simple jsp with exaclty the same code and it was able to lookup successfully.
JBoss AS 7 and JBoss EAP 6, differently from the older versions, start all services in parallel and for some reason the Stateless Session Bean hasn't have it's JNDI bind in time. Note that the application.xml was ok, with the ejb jar coming first, even so it seemed that the order wasn't being making a difference:
<module> <ejb>my-ejb.jar</ejb> </module> <module> <web> <web-uri>my-web.war</web-uri> </web> </module>
Then I saw a "light in the end of the tunnel" with the "initialize-in-order" attribute added to application.xml, it forces JBoss to keep the application.xml ordering.
<initialize-in-order>true</initialize-in-order>
By setting initialize-in-order attribute, ejb.jar was deployed before the .war and the ServletContextListener implementation with the Stateles Session Bean worked just fine.
More about this in the EAP 6 Migration Guide.
More about this in the EAP 6 Migration Guide.
Hope it helps you guys to save some time.