title: EJB3 Weblogic 10.3.6 JNDI lookup
body: <p>I am getting a javax.naming.NameNotFoundException: While trying to look up a EJB3 Stateless session bean. </p>
  
  <p>I have 1 weblogic domain and it consists of two servers Server_1 and server_2. I have deployed a EAR file to server_2 which consists of a EJB3 deployment. It has the following inside it </p>
  
  <pre><code>EJB3 EAR file
  ----EJB3 Module Jar file
      ------Stateless session EJB3 bean 
  ----META-INF Folder
      -- application.xml file
  ----lib folder
      -------EJB3 Client jar holding containing remote  and local interface
  </code></pre>
  
  <p>The EJB3 Module jar file consists of following</p>
  
  <pre><code>EJB3 JAR file
      ----package structure of EJB3 Stateless bean and bean 
      ----META-INF folder
          -----weblogic-ejb-jar.xml
          -----ejb-jar.xml. 
  </code></pre>
  
  <p>On server 1 I have deployed my EJB3 Client Jar which has my remote interface inside it. On this server I have also 
  deployed another jar file which will use the remote interface of the client jar to lookup the ejb. </p>
  
  <p>my EJB3 is below</p>
  
  <pre><code>@Remote
  public interface ContractorIdRemote {
      public String test();
  }
  
  @Stateless(name="ContractorIdBean", mappedName="ContractorIdBean")
  public class ContractorIdBean implements ContractorIdRemote {
  
      public String test() {
          .........
      }
  }
  </code></pre>
  
  <p>my ejb-jar file is as follows</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ASCII"?&gt;
  &lt;ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0"&gt;
  &lt;display-name&gt;ejb&lt;/display-name&gt;
  &lt;enterprise-beans&gt;
       &lt;session&gt;
            &lt;ejb-name&gt;ContractorIdBean&lt;/ejb-name&gt;
            &lt;ejb-ref&gt;
                 &lt;ejb-ref-name&gt;ContractorIdBean&lt;/ejb-ref-name&gt;
                 &lt;remote&gt;com.ejb3.websphere.ContractorIdRemote&lt;/remote&gt;
                 &lt;mapped-name&gt;ContractorIdBean&lt;/mapped-name&gt;
            &lt;/ejb-ref&gt;
       &lt;/session&gt;
  &lt;/enterprise-beans&gt;
  &lt;/ejb-jar&gt;
  </code></pre>
  
  <p>the weblogic-ejb xml file</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE weblogic-ejb-jar PUBLIC
  '-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN'
  'http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd'&gt;
  
  &lt;weblogic-ejb-jar&gt;
  
  
      &lt;weblogic-enterprise-bean&gt;
          &lt;ejb-name&gt;ContractorIdBean&lt;/ejb-name&gt;
          &lt;jndi-name&gt;ejb/ContractorIdBean&lt;/jndi-name&gt;
      &lt;/weblogic-enterprise-bean&gt;
  
  
  
  &lt;/weblogic-ejb-jar&gt;
  </code></pre>
  
  <p>My lookup is done as follows from the calling client</p>
  
  <pre><code>Context ctx = new InitialContext(properties);
  ContractorIdRemote cRemote = (ContractorIdRemote)ctx.lookup("ejb/ContractorIdBean");
  cRemote.test();
  </code></pre>
  
  <p>my properties file has the following </p>
  
  <pre><code>java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
  java.naming.provider.url=t3://localhost:17001
  </code></pre>
  
  <p>But obviously ejb/ContractorIdBean is not what it is bound with. I can see the EAR is deployed on server_2 successfully </p>
  
  <p>Can anyone please advice what I should use to lookup the ejb. I have tried the following but all with namenotfound exception</p>
  
  <pre><code>java:comp/env/ejb/ejb/ContractorIdBean
  java:comp/env/ejb/ContractorIdBean
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <p>UPDATE:</p>
  
  <p>I changed my jndi name to just contractorIdBean and as before I can see in the jndi tree on the server the binding name ContractorIdBean#com.ejb3.websphere.ContractorIdRemote</p>
  
  <p>But this still throws a Name not found exception</p>
  
  <p><img src="https://i.stack.imgur.com/GRsr3.jpg" alt="enter image description here"></p>
  
  <p>UPDATE AGAIN:</p>
  
  <p>I changed the jndi name to the screenshot above and added the security credentials for the server. Following this I get the following exception now </p>
  
  <pre><code>javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: failed to unmarshal class java.lang.Object; nested exception is: 
      java.lang.ClassNotFoundException: com.ejb3.websphere.ContractorIdRemote]
  </code></pre>
  
  <p>I am not sure why it cannot find the class. I have also included it in the deployed EAR file on server_2 as well as in the ejb client jar on server 1</p>