title: Run-time lookup for EJBs in MDB consuming immediately after deploy
body: <p>I have Java EE 5 project using JBoss 5.1 and problem like this. I have to do kind of run-time lookup for some EJBs in MDBs using a string that results from message content. It's just kind of service locator pattern used in MDBs. Now, since MDBs start consuming just after deploy, I have a lot <code>NameNotFoundException</code> since implicit deployment order doesn't work well here (run-time lookup). What do you think about it? Is it possible to do it really well using EJB 3.0? It's also acceptable for me to use any vendor-specific stuff (JBoss 5.1) if it resolves the problem.</p>
  
  <p>Some code snippet to visualize the situation:</p>
  
  <pre><code>@MessageDriven(mappedName="jms/Queue")
  public class MessageBean implements MessageListener {
  
      @Resource
      private MessageDrivenContext mdc;
  
      public void onMessage(Message msg) {
  
          final String beanName = // extract somehow the bean's name from 'msg'
          final Context ctx = new InitialContext();
          final Object obj = ctx.lookup(beanName); // NameNotFoundException
          // do something with 'obj'
      }
  }
  </code></pre>