0 Replies Latest reply on Nov 28, 2010 8:13 PM by 819036

    Doing a jndi lookup() for an EJB deployed on Glassfish v3


      I have deployed a Stateful Sesion EJB on a Glassfish v3 AppServer.
      It is running under 'localhost' on my laptop pc.

      I am also running a stand-alone java application on the same pc... it attempts to get a remote connection from the client-app to the Glassfish Server and then do a jndi lookup() to get a reference to my EJB.

      here is the client source code:

      public class LookupTest {

      static Properties props = null;

      public static void main(String[] args) {

      try {
      props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
           props.put(Context.PROVIDER_URL, "iiop://localhost:3700");

           Context ctx = new InitialContext(props);
           System.out.println( "the context is: " + ctx);
           System.out.println( "the environment contains: " + ctx.getEnvironment() );
           System.out.println( " ");

           // do a lookup.
           Object elementObj = ctx.lookup("SerialContextProvider");

      } catch (NamingException e) {

      When I run this app, there are no Errors or Exceptions. It appears that the connection succeeds. But there are no EJB references in the context that is created. The only item that seems to be present in the context is an item named "SerialContextProvider", as noted in the return value from a list("") method invocation. Why can i not see the EJB within the context? Is my code wrong ??


      Andy Jerpe

      Edited by: user1169567 on Nov 28, 2010 12:12 PM