Discussions

Web tier: servlets, JSP, Web frameworks: hi,about using a sesion bean in another weblogic server?

  1. hi,
      I have registered a servlet in a local machine,which install a weblogic 5.1 server. And in this servlet ,I will call a session bean in another machine(I know it's Ip Address.).I have tried.but fails.
    Just can not find the session Bean.
    the code is:
      try{
                Context ctx=getInitialContext();
                out.println("context is "+ctx);
              Object object=ctx.lookup("UserAuthentication");
    UserAuthenticationHome home=(UserAuthenticationHome)javax.rmi.PortableRemoteObject.narrow(object,UserAuthenticationHome.class);
    ...
     static public Context getInitialContext() throws Exception {
        Properties p = new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,
            "weblogic.jndi.WLInitialContextFactory");
        p.put(Context.PROVIDER_URL, url);//
    if (user != null) {
    p.put(Context.SECURITY_PRINCIPAL, user);
    if (password == null)
    password = "";
    p.put(Context.SECURITY_CREDENTIALS, password);
    }
    return new InitialContext(p);
    }
    static String url = "t3://102.226.180.108:7001";//another machine
    static String user = null;
    static String password = null;

      Please give me help!
    thanks
    zhousr
  2. make sure that stubs(of the ejb object) generated by ejbc are present in the classpath of the client.
  3. You should _not_ need to have the stubs on the client. They should be sent over the wire from the server in exactly the same way as they are to any other EJB client.

    Note: The above is not true with WebLogic 5.1.0 IF the two servers are in a cluster, it's a known bug, due to be fixed in SP9.

    Try skipping the authentication lines in the inital context set up. Not sure how it reacts to nulls as opposed to not provided.

    Chz

    Tony