I'm developing in Netweaver 2004s, EJB 2.0.
I'm trying to access my EJB that located at another server using the remote EJB method. It is a EJB 2.0. Here are my code.
...
try{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL, "192.0.0.1:50004");
props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services");
InitialContext ctx = new InitialContext(props);
Object obj = ctx.lookup("sap.com/HelloWorldEAR/HelloWorldBean");
HelloWorldHome helloHome = (HelloWorldHome) PortableRemoteObject.narrow(obj, HelloWorldHome.class);
HelloWorld hRef = helloHome.create();
String msg = hRef.printMsg();
.......
}
When i tried to run it, it printout this error.
com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at HelloWorldEAR, the whole lookup name is sap.com/HelloWorldEAR/HelloWorldBean
I'm not sure is it connected to the remote server and try to find my EJB or it unable to connect at all as both is different issue.
I tried access to the local EJB that i deployed in the same server using this method.
Context ic = new InitialContext();
HelloWorldHome home = (HelloWorldHome)ic.lookup("OUTBOUND");
helloLocal = home.create();
It is working fine. My Stateless Session Bean i register the JNDI as OUTBOUND. So am wondering i need to do it this way for my remote EJB also?
Object obj = ctx.lookup("sap.com/HelloWorldEAR/HelloWorldBean");
Change to
Object obj = ctx.lookup("sap.com/HelloWorldEAR/OUTBOUND");
I tried by seem not working also. Anyone can englight me. Appreciate the help.