title: How to dynamically lookup an EJB at runtime
body: <p>I have this scenario where i have my EJB3 beans in a jar file, deployed successfully to Jboss EAP-6.4. </p>
  
  <p>Then I have another web project that looks up these EJB's inside a REST POJO class. I can currently access the EJB's from inside the web project using <code>@Inject</code> and <code>@EJB</code>, but my use case is one that i don't know which beans i need to load until runtime and the list is not static, so i might need to lookup 10 EJB's or none for a particular request etc.</p>
  
  <p>I know I can possibly use </p>
  
  <pre><code>InitialContext.lookup('ejb:/.....')
  </code></pre>
  
  <p>to retrieve my EJB beans from inside the web project, but is there a way that i can retrieve them without that round trip(i believe), or maybe what am just looking for is a more elegant way to do EJB look-up at runtime just like the statically typed <code>@EJB</code> and <code>@Inject</code> versions.</p>
  
  <p>Any suggestions are greatly appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>In my REST POJO classes i don't want to hard code any @Inject or @EJB annotations, rather i want that when a request comes in i look-up(for lack of better word) the EJB's that will handle the request, so all the decision is made at runtime really, as shown below</p>
  
  <pre><code>@Path("/path")
  public class TestService {
  
      @GET("/{id}")
      public String loadGetPath(@Param id int id){
          //at this point i want to dynamically resolve the EJB based on 
          //the value of id
      }
  }
  </code></pre>