How can I communicate to EJB in another server?
Continue Reading This Article
Enjoy this article as well as all of our content, including E-Guides, news, tips and more.
Properties props = new Properties(); props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); props.put(javax.naming.Context.PROVIDER_URL, "t3://myhost:7001"); props.put(javax.naming.Context.SECURITY_PRINCIPAL, "jdoe"); props.put(javax.naming.Context.SECURITY_CREDENTIALS, "foobar"); javax.naming.Context context = new javax.naming.InitialContext(props); Object homeObject = context.lookup("java:comp/env/myejb"); MyEJBHome home = null; if (usingIIOP == true) { home = (MyEJBHome)PortableRemoteObject.narrow(homeObject, MyEJBHome.class); } else { home = (MyEJBHome)homeObject; } MyEJB myEJB = MyEJBHome.create();
javax.naming.Context context = new javax.naming.InitialContext(); Object homeObject = context.lookup("java:comp/env/myejb"); MyEJBHome home = (MyEJBHome)homeObject; MyEJB myEJB = MyEJBHome.create();