Badri,
Thank you for the response. I am running the application on my local machine using the Sun Java System Application Server PE 8.2. I made some changes to the code but don't really know what I am trying to achieve here? When I tried to run the code I received the error below.
1) How can I retrieve the correct initial_context_factory
2) How can I retrieve the correct provider_url of the server?
Thanks again
Clinton
Error Message
javax.naming.NamingException: Cannot parse url:
iiop://localhost:3700 [Root exce
ption is java.net.MalformedURLException: Not an LDAP URL:
iiop://localhost:3700] at com.sun.jndi.ldap.LdapURL.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at AdviceClient.go(AdviceClient.java:20)
at AdviceClient.main(AdviceClient.java:12)
Caused by: java.net.MalformedURLException: Not an LDAP URL:
iiop://localhost:3700 Class
import javax.naming.Context;
import javax.naming.InitialContext;
import java.rmi.*;
import java.util.Hashtable;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;
public class AdviceClient {
public static void main(String[] args){
new AdviceClient().go();
}
public void go(){
try{
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:3700");
Context ctx = new InitialContext(env);
Object o = ctx.lookup("ejb/Advisor");
AdviceHome home = (AdviceHome)PortableRemoteObject.narrow(o, AdviceHome.class);
Advice advisor = home.create();
System.out.println(advisor.getMessage());
}
catch(Exception ex){
ex.printStackTrace();
}
}
}
[ November 12, 2007: Message edited by: Clinton Morrison ]