title: Object reference lookup from JNDI results in ClassCastException
body: <p>I'm having problems calling EJB3 stateless bean outside the container.</p>
  
  <p>Code for getting the object reference:</p>
  
  <pre><code>Context envCtx = (Context) context.lookup("ejb");
  MyObject o = (MyObject) envCtx.lookup(MyObject);
  </code></pre>
  
  <p>The second row results in exception:</p>
  
  <pre><code>java.lang.ClassCastException: javax.naming.Reference
  </code></pre>
  
  <p>I use JBoss.org 5.1.0 GA.</p>
  
  <p>Based on some other posts I suspect this might be due to wrong version of client libraries. However, I'm unsure which library jar(s) I should include in the jar? (I get the error using 5.0.4.GA jnpserver.)</p>