Unable to connect to an EJB fom a standlone java ejb client
843830Jan 25 2005 — edited Jun 21 2006Hello All,
I have developed and deployed an EJB in WSAD 5.1.2's WebSphere 4.0 Test Environment. However when I run it I am getting below error. I have used IBM JDK/JRE to compile and run my client program. The same illustration holds for running a standlone web service client program written using axis stubs.
error
-----------------------------------------------------------------------
javax.naming.CommunicationException: A communication failure occurred while attempting to obtain an initial context with the
provider URL: "iiop://localhost:2809/". Make sure that any bootstrap address information in the URL is correct and that the
target name server is running. A bootstrap address with no port specification defaults to port 2809. Possible causes other
than an incorrect bootstrap address or unavailable name server include the network environment and workstation network config
uration. [Root exception is org.omg.CORBA.COMM_FAILURE: WRITE_ERROR_SEND_1 minor code: 49421050 completed: No]
-----------------------------------------------------------------------
The path and classpath I have used to run my EJBClient.java are as follows :
---------------------------
set WSAD_HOME=D:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5
set path=D:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\java\bin;
set classpath=.;%WSAD_HOME%\java\jre\lib\rt.jar;%WSAD_HOME%\lib\j2ee.jar;%WSAD_HOME%\lib\ltext.jar;%WSAD_HOME%\lib\namingclient.jar;%WSAD_HOME%\lib\ecutils.jar;%WSAD_HOME%\lib\lmproxy.jar;%WSAD_HOME%\lib\bootstrap.jar;%WSAD_HOME%\properties;
Below is the command I have used for running my client :
java -Dcom.ibm.CORBA.ConfigURL="%WSAD_HOME%\properties\sas.client.props" -Dserver.root="%WSAD_HOME%" -Dws.ext.dirs="%WSAD_HOME%\java\lib;%WSAD_HOME%\classes;%WSAD_HOME%\lib;%WSAD_HOME%\lib\ext" -Djava.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory -Xbootclasspath/p:"%WSAD_HOME%\java\jre\lib\ext\ibmorb.jar;%WSAD_HOME%\properties" EJBClient
Below is my complete EJB Client
--------------------------------
public class EJBClient {
public static void main(String[] args) {
try {
java.util.Hashtable env = new java.util.Hashtable();
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:2809/");
javax.naming.Context ctx = new javax.naming.InitialContext(env);
Object homeObject = ctx.lookup("ejb/DemoHome");
DemoHome accessHome = (DemoHome)javax.rmi.PortableRemoteObject.narrow(homeObject, DemoHome.class);
Demo demoBean = accessHome.create();
AccountHistory hist = demoBean.getAccountHistory("first", "second", 0, null);
}
catch (Exception e) {
System.out.println(e);
}
}
}
Please suggest ...
Thanks & Regards,
Kumar.