Discussions

EJB design: Can we dynamically know the servername?

  1. Can we dynamically know the servername? (1 messages)

    private InitialContext getInitialcontext() throws NamingException
    {
    Properties env = new Properties();
    try{

    env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL,"t3://localhost:7001");
    }catch(Exception e){
    System.out.print("Connection to the weblogic server is not there. " +
    e );
    }
    return new InitialContext(env);
    }

    this is how u get the InitialContext for doing the jndi lookup.
    here we have hard coded the url as "t3://localhost:7001"
    but there is some way through which we can dynamically
    know the servername
  2. I dont' know if this works in weblogic or not, but in other EJB servers, you can place a file in the same directory as your executable called jndi.properties, which is basically a properties file that sets the values that you are setting explicitly here.