javanetweaver

Where is EJB method run


I'm calling an EJB method remotely using next code:

RemCallRemote rc = null;
String Text = "";   
Properties props = new Properties();    

//Filling the properties for connection to a remote server
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

props.put(Context.PROVIDER_URL, "hostaddress:50004");

props.put(Context.SECURITY_PRINCIPAL, "LOGINNAME");

props.put(Context.SECURITY_CREDENTIALS, "*****");  

props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services");    

InitialContext ctx = new InitialContext(props);

//getting a reference to an interface
rc = (RemCallRemote)ctx.lookup("ejb:/appName=sap.com/RemoteCallEAR, jarName=RemoteCallEJB.jar, beanName=RemCall, interfaceName=RemCallRemote");

//calling an EJB method
Text = rc.Check();

The code works fine, but my question is: Where is the EJB method run? Is it run always on 'hostaddress' machine or anywhere else?


Solution

  • The host address is where the JNDI server is. It's not always the same server where the EJB's themselves are running, though in most cases it is.

    For exceptional cases, you can register an EJB from server1 in a JNDI server on server2 that serves as some sort of cluster manager. Not really sure if it's possible with SAP, but on e.g. WebSphere you can.