Topic
  • 3 replies
  • Latest Post - ‏2012-06-21T06:26:01Z by Shawn_Jiang
C568_Subir_Ghosh
C568_Subir_Ghosh
4 Posts

Pinned topic How to connct to a jndi name configured in WAS 7 from WASCE 2.1 ?

‏2012-06-13T09:38:20Z |
Hello,
I would like to know how to connect to a jndi name defined in Websphere Application Server 7 (WAS 7) from an application in WAS CE 2.1.

Both the servers are in different machines (i.e, different IP addresses).

Any help would be much appreciated.
Updated on 2012-06-21T06:26:01Z at 2012-06-21T06:26:01Z by Shawn_Jiang
  • X75J_Li_Yanli
    X75J_Li_Yanli
    45 Posts

    Re: How to connct to a jndi name configured in WAS 7 from WASCE 2.1 ?

    ‏2012-06-20T04:44:25Z  
    Hi,

    What's your jndi name looks like? for general applications,they are allowed to find the object in jndi tree on the server that they were deployed.
  • X75J_Li_Yanli
    X75J_Li_Yanli
    45 Posts

    Re: How to connct to a jndi name configured in WAS 7 from WASCE 2.1 ?

    ‏2012-06-20T14:01:01Z  
    Basically, not every server provided remote JNDI support.But some of them do provide this,like openejb and activemq. Take openejb as an example:
    1. Put a openejb-client.jar in your classpath.
    2. Set java.name.factory.initial to a remote initial context factory impl.
    3. Set provider url to the remote JNDI listening endpoint.
    4. Use common jndi lookup actions with the initial context instance.
  • Shawn_Jiang
    Shawn_Jiang
    154 Posts

    Re: How to connct to a jndi name configured in WAS 7 from WASCE 2.1 ?

    ‏2012-06-21T06:26:01Z  
    A quick google gave me this[1]:

    Each server contains its own server root context, and, when bootstrapping to a server, the server root is the default initial JNDI context. Most of the time, this default is the desired initial context, since system artifacts such as EJB homes are bound there. However, other root contexts exist, which can contain bindings of interest. It is possible to specify a provider URL to select other root contexts. Sample:

    ...
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    ...
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.ibm.websphere.naming.WsnInitialContextFactory");
    env.put(Context.PROVIDER_URL,
    "corbaloc:iiop:myhost.mycompany.com:2809/NameServiceCellPersistentRoot");
    Context initialContext = new InitialContext(env);
    ...

    [1]http://pic.dhe.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=%2Fcom.ibm.websphere.javadoc.doc%2Fpublic_html%2Fapi%2Fcom%2Fibm%2Fwebsphere%2Fnaming%2FWsnInitialContextFactory.html

    Based on what's the server root context you want to access in WebSphere server, you'll need to configure corresponding INITIAL_CONTEXT_FACTORY and PROVIDER_URL before create your initial context instance.

    Anyway, this is the forum for WAS Community Edition/Geronimo. If you want to know more about the WebSphere Application Server JNDI. you can post your question to WebSphere Application Server forum.