title: InitialContext.lookup() parameter in JBoss 7.1
body: <p>I am new in the world of EJB 3.1 and trying to get some basics with the JBoss Application Server 7.1. </p>
  
  <p>At the moment I am stuck at a - really basic - problem. When a bean on the server wants to use another bean I need to use the InitialContext.lookup() method. If I look in the literature I found calls like:</p>
  
  <pre><code>TheBean = (&lt;Interface&gt;) new InitialContext().lookup("&lt;NameOfTheBean&gt;/local");
  </code></pre>
  
  <p>But this call doesn’t work for me. Every time I get an error like this:</p>
  
  <pre><code>javax.ejb.EJBException: javax.naming.NameNotFoundException
  </code></pre>
  
  <p>After hours of looking for a solution I found code examples which use another call, something like this: </p>
  
  <pre><code>TheBean = (&lt;Interface&gt;) new InitialContext().lookup("ejb:/&lt;Package&gt;//&lt;NameOfTheBean&gt;!&lt;Package&gt;.&lt;Interface&gt;");
  </code></pre>
  
  <p>Well this solution works for me but the question is why? Does somebody know why the first call produces exceptions while the second one works fine?</p>
  
  <p>Thanks a lot!</p>