We know that when a test client is located on the same machine as the deployed beans,it can access the beans like this:(take the bean's name as Hello)
Context context = getInitialContext();
//look up jndi name
Object ref = context.lookup("Hello");
//look up jndi name and cast to Home interface
helloHome = (HelloHome) PortableRemoteObject.narrow(ref, HelloHome.class);
Specifically,when we get the IitialContext,the code may be:
private Context getInitialContext() throws Exception {
String url = "t3://localhost:7001";
String user = null;
String password = null;
Properties properties = null;
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
return new InitialContext(properties);
}
So the question is:if I want to access the Hello bean from a remote machine,how will the client code look like?I tried to modify the PROVIDER_URL as :
String url="http://EJB server address:7001",but it turned to be a failure.What shoud I do?What's the meaning for "t3"?
-
how to access deployed beans form remote machines? (2 messages)
- Posted by: spears tian
- Posted on: September 24 2003 06:13 EDT
Threaded Messages (2)
- how to access deployed beans form remote machines? by stephen smithstone on September 24 2003 07:23 EDT
- how to access deployed beans form remote machines? by David Rabinowitz on September 24 2003 08:43 EDT
-
how to access deployed beans form remote machines?[ Go to top ]
- Posted by: stephen smithstone
- Posted on: September 24 2003 07:23 EDT
- in response to spears tian
We know that when a test client is located on the same machine as the deployed beans,it can access the beans like this:(take the bean's name as Hello)
> Context context = getInitialContext();
> //look up jndi name
> Object ref = context.lookup("Hello");
> //look up jndi name and cast to Home interface
> helloHome = (HelloHome) PortableRemoteObject.narrow(ref, HelloHome.class);
>
> Specifically,when we get the IitialContext,the code may be:
> private Context getInitialContext() throws Exception {
> String url = "t3://localhost:7001";
> String user = null;
> String password = null;
> Properties properties = null;
> properties = new Properties();
> properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
> properties.put(Context.PROVIDER_URL, url);
> if (user != null) {
> properties.put(Context.SECURITY_PRINCIPAL, user);
> properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
> return new InitialContext(properties);
> }
>
> So the question is:if I want to access the Hello bean from a remote machine,how will the client code look like?I tried to modify the PROVIDER_URL as :
> String url="http://EJB server address:7001",but it turned to be a failure.What shoud I do?What's the meaning for "t3"?
use the t3://ejb_server:7001 as the url string in the remote client ,as the t3 is the protocol of the server so an http will fail -
how to access deployed beans form remote machines?[ Go to top ]
- Posted by: David Rabinowitz
- Posted on: September 24 2003 08:43 EDT
- in response to stephen smithstone
Also, I'm sure weblogic has some kind of client.jar with the neccessary classes.