title: EJB remote lookup fails with javax.naming.NameNotFoundException
body: <p>I am testing EJB Client in the JBOSS 7.1.1 server. The Service side code of the EJB is also on the same VM. It throws " java.lang.ClassNotFoundException: com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote" error during runtime. Everything seems to be right in setting up the client but i couldn't figure out the issue is. Please let me know where i am doing wrong. </p>
  
  <p><strong>Server Side Code</strong></p>
  
  <pre><code>@Stateless(name = "WhiteBoardService")
  @Local(IWhiteBoardService.class)
  @Remote(IWhiteBoardServiceRemote.class)
  public class WhiteBoardService implements IWhiteBoardService {
  
      private WhiteBoardPersistenceImpl whiteBoardPersistenceImpl = WhiteBoardPersistenceImpl
              .getInstance();
      private CoursePersistenceImpl coursePersistenceImpl = CoursePersistenceImpl
              .getInstance();
  
      @Override
      public LongKeyValue[] getWhiteBoardContent(long courseSessionGuid, UserSession userSession) {
          // returns the attachment Guid and the Attachment Title
          return whiteBoardPersistenceImpl.getAttachmentForWhiteBoard(courseSessionGuid, userSession) ;
      }......
  </code></pre>
  
  <p>Local Interface</p>
  
  <pre><code>@Local
  public interface IWhiteBoardService {
  
      public WhiteBoardSessionVO openWhiteBoard(long courseSessionGuid, UserSession userSession);
      public WhiteBoardSessionVO joinWhiteBoard(long courseSessionGuid,UserSession userSession);
      public LongKeyValue[] getWhiteBoardContent(long courseSessionGuid, UserSession userSession);
  }
  </code></pre>
  
  <p>Remote Interface</p>
  
  <pre><code>public interface IWhiteBoardServiceRemote extends IWhiteBoardService{
  
  
  }
  </code></pre>
  
  <p><strong>EJB is already Deployed</strong></p>
  
  <pre><code>20:42:32,278 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named WhiteBoardService in deployment unit subdeployment "emyed-ejb-1.0.jar" of deployment "emyed-ear.ear" are as follows:
  
      java:global/emyed-ear/emyed-ejb-1.0/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote
      java:app/emyed-ejb-1.0/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote
      java:module/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote
      java:jboss/exported/emyed-ear/emyed-ejb-1.0/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote
      java:global/emyed-ear/emyed-ejb-1.0/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardService
      java:app/emyed-ejb-1.0/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardService
      java:module/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardService
  </code></pre>
  
  <p><strong>Client Class</strong></p>
  
  <pre><code>public class WhiteboardService {
  
      public static void main(String[] args){
  
          Context context=null;
             try
               {
                      Properties props = new Properties();
                      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                      props.put(Context.PROVIDER_URL, "remote://localhost:4447");
                      props.put(Context.SECURITY_PRINCIPAL, "ejbremote");
                      props.put(Context.SECURITY_CREDENTIALS, "remote4u");
                      context = new InitialContext(props);
                  System.out.println("\n\tGot initial Context: "+context);
               }
             catch (Exception e)
               {
                      e.printStackTrace();
                }
  
               // Lookup Format will be
               // &lt;app-name&gt;/&lt;module-name&gt;/&lt;distinct-name&gt;/&lt;bean-name&gt;!&lt;fully-qualified-classname-of-the-remote-interface&gt;
  
             IWhiteBoardServiceRemote whiteboardService = null;
          try {
              Object obj = context.lookup("java:jboss/exported/emyed-ear/emyed-ejb-1.0/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote");
          } catch (NamingException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
               System.out.println("\n\t (\"MiddlewareMagic\") = "+ whiteboardService.getWhiteBoardContent(1, null));
  
      }
  </code></pre>
  
  <p><strong>Console Log</strong></p>
  
  <pre><code>02:13:45,303  INFO xnio:63 - XNIO Version 3.0.3.GA
  02:13:45,355  INFO nio:55 - XNIO NIO Implementation Version 3.0.3.GA
  02:13:45,469  INFO remoting:70 - JBoss Remoting version 3.2.3.GA
  
      Got initial Context: javax.naming.InitialContext@5a92668c
  javax.naming.NameNotFoundException: jboss/exported/emyed-ear/emyed-ejb-1.0/WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote -- service jboss.naming.context.java.jboss.exported.jboss.exported.emyed-ear."emyed-ejb-1.0"."WhiteBoardService!com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote"
      at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
      at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
      at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  Exception in thread "main" java.lang.NoClassDefFoundError: com/zreflect/emyed/ejb/interfaces/IWhiteBoardServiceRemote
      at com.zreflect.emyed.whiteboard.service.WhiteboardService.main(WhiteboardService.java:47)
  Caused by: java.lang.ClassNotFoundException: com.zreflect.emyed.ejb.interfaces.IWhiteBoardServiceRemote
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      ... 1 more
  </code></pre>