Discussions

EJB design: JNDI problem

  1. JNDI problem (4 messages)

    I was trying to look up a ejb component
    on a weblogic server in network from my JSP page in another weblogic server
    it is able to Look up server resourses like(Datasources)
    but not any ejb's

    ******************
    THIS IS NOT WORKING


    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL,"t3://192.168.1.24:7001");
    env.put(Context.SECURITY_PRINCIPAL, "system");
    env.put(Context.SECURITY_CREDENTIALS,"weblogic");

       Context ctx = new InitialContext(env);
       Object ref= ctx.lookup("JNDICUSTOMER");
    System.out.println("After the look up");

    Threaded Messages (4)

  2. JNDI problem[ Go to top ]

    Hi,

    I assume that u r not much familiar with how jndi works.
    JNDI stores every name with specific context. For any object u should specify context also, so as not to confuse JNDI in case there are more than 1 occurance of same name.

    As per my knowledge, in case of weblogic, the object name without context is mapped to EJB or remote object, by jndi. For accessing any other objects like connection pool, on weblogic atlease, u should use something like

    "java:comp/env/jdbc/demoPool"

     where demo pool is the connection pool to be looked up in JNDI, as an argument to lookup method.

    This string is internally converted to context by weblogic & JNDI will give u proper object.

    For more details, kindly go thru weblogic's example of bean managed account & ofcourse, documentation. That should help u accessing resources using JNDI.

    Kailash
  3. JNDI problem[ Go to top ]

    hi,

     i dont think you got my problem right,
    i asked for a way to contact a component on one server from other app server,
    the context what u said is not the solution for that
    using the context is not a great thing try for my problem
    any way thanx
    for your
    reply
  4. Hi,

    All EJBs act as normal client, when it comes to invoking method on some other EJB that may be deployed on the same server or different server itself. There is no way for any EJB to find out whether caller of method is another EJB or application or applet ...

    Also there is no API for any EJB to invoke another EJB. U have to follow the same route, as other type of clients( applications or applet) would have taken. This is intended, as container can then carry out all the state management related activities more uniformly.

    Cheers,
    Kailash
  5. JNDI problem[ Go to top ]

    Check that you are using the correct name. Look at the beans weblogic-ejb-jar.xml file and locate the <jndi-name> tag. This is the string to use in the lookup.

    e.g. if this is in the XML file
    <jndi-name>BankAccountEJB</jndi-name>

    use this in your lookup:
    ctx.lookup("BankAccountEJB");

    You can use the Weblogic consoles Naming screen to examine the entire contents of the WLS Naming Service.