3 Replies Latest reply on Jul 1, 2010 12:41 AM by dvohra21

    jndi lookup of remote EJB, using weblogic.xml

      From within a servlet, I'd like to call an EJB 2.0 session bean on a remote server. Both
      appservers are weblogic 10.32.

      I can see how I can configure the InitialContext to set the URL and credentials, e.g.,:

      p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      p.put(Context.PROVIDER_URL, "t3://myhost.somewhere.com:8002");
      p.put(Context.SECURITY_PRINCIPAL, "system");
      p.put(Context.SECURITY_CREDENTIALS, "weblogic");
      Context context = new InitialContext(p);
      Object obj = context.lookup("java:comp/env/ejb/HelloWorldBean");

      However, it seems to me to be better to instead configure the lookup in the
      deployment descriptor (i.e., not pass the properties to the InitialContext). I have
      managed to get the following working in the weblogic.xml for the servlet:


      But I don't know how to provide the security principals/credentials in this case. I've
      been searching the web/documentation all day. :(

      Any help/pointers would be greatly appreciated!
        • 1. Re: jndi lookup of remote EJB, using weblogic.xml
          Jay SenSharma MiddlewareMagic

          Lookup in the JNDI tree...by default doesnt requires any Authentication. It means without using the Username & Password Informations u should be able to lookup your EJBs even if it is Located in a Remote Server. You need to pass the Credentials inside the Hashtable ....Only if your have secure the JNDI lookup of your EJBs....Which generally we dont do.

          NOTE: Securing JNDI tree for Lookup is not related to EJBs....EJB Layer Security is different from JNDI level security....So using Deployment descriptor Tags <ejb-reference-description> You cannot make your EJB secure , You can just refer to it....For Lookup and access a JNDI tree u need to have Security implemented at JNDI layer...so naturally the JNDI Access/Authentication will be limited to JNDI lookup layer only.....

          <font color=red>
          Even there is NO mapping (Tag) available inside deployment descriptor as part of Tag <ejb-reference-description> ..which can be used.
          *<ejb-reference-description>* can be used to refer to an EJB which is deployed on the Same Server...*u CANNOT even use it to access (reference) and EJB which is deployed on a Remote Server.*
          </font>... Still if you want to authenticate a User ...before he looks up to the remote EJB ..then u need to provide authentication at the Web Layer.
          Jay SenSharma
          http://weblogic-wonders.com/weblogic (WebLogic Wonders Are Here)
          • 2. Re: jndi lookup of remote EJB, using weblogic.xml
            Thanks Jay ... that's the information I was missing.
            • 3. Re: jndi lookup of remote EJB, using weblogic.xml
              Use the mapped name for session bean. The format of the global JNDI name is mappedName#qualified_name_of_businessInterface.
              <remote_interface> beanRemote = (<remote_interface>) context.lookup("mappedName#qualified_name_of_businessInterface");