This depends upon your deployment. Making an MBean depend upon EJB
will often promote the EJB to before other deployments, which means those other
deployments have not started yet and hence have not been bound to JNDI.
If it is random, then most likely you are missing a dependency. Sometimes
you get the right order, sometimes you don't, probably depending upon
the creation timestamps of the deployments. i.e. the order of the directory listing.