Hi Gurus,
I have configured the datasource on WebSphere v5.0
Test Environment and trying to access it from the stand alone client (say, a
JUnit test class) in a
java project. When I execute the test class, I get the following error.
Appreciate your help and suggestions.
Smitha
==========================================================================
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 configuration. Root exception is org.omg.CORBA.COMM_FAILURE: WRITE_ERROR_SEND_1 minor code: 49421050 completed: No
at com.ibm.ws.orbimpl.transport.HTTPOutputStream.write(Unknown Source)
at com.ibm.rmi.iiop.IIOPOutputStream.writeTo(IIOPOutputStream.java:283)
at com.ibm.rmi.iiop.Connection.send(Connection.java:1485)
at com.ibm.rmi.iiop.Connection._locate(Connection.java:265)
at com.ibm.rmi.iiop.Connection.locate(Connection.java:244)
at com.ibm.rmi.iiop.GIOPImpl.locate(GIOPImpl.java:184)
at com.ibm.rmi.corba.Corbaloc.locateUsingINS(Corbaloc.java:305)
at com.ibm.rmi.corba.Corbaloc.resolve(Corbaloc.java:367)
at com.ibm.rmi.corba.ORB.string_to_object(ORB.java:2941)
at com.ibm.ws.naming.util.WsnInitCtxFactory.stringToObject(WsnInitCtxFactory.java:1256)
at com.ibm.ws.naming.util.WsnInitCtxFactory.mergeWsnNSProperties(WsnInitCtxFactory.java:1107)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootContextFromServer(WsnInitCtxFactory.java:679)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:607)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:482)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:112)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:422)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:143)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at org.kp.sql.helper.DataSourceUtil.initializeDataSource(DataSourceUtil.java:90)
at org.kp.sql.helper.DataSourceUtil.getDataSource(DataSourceUtil.java:61)
at org.kp.sql.helper.CommonDAO.retrieveListFromDB(CommonDAO.java:79)
at org.kp.message.dao.impl.MessageDAOImpl.retrieveMessage(MessageDAOImpl.java:89)
at org.kp.message.service.impl.MessageServiceImpl.retrieveMessages(MessageServiceImpl.java:258)
at org.kp.message.service.impl.MessageServiceImpl.findMessage(MessageServiceImpl.java:65)
at org.kp.message.util.MessageServiceUtil.getMessage(MessageServiceUtil.java:72)
at org.kp.message.test.TestMessageManager.main(TestMessageManager.java:10)
Exception in
thread "P=801061

=0:CT"
===========================================================================
The following jars added in the classpath for the java project.
--------------------------------------------------------------
1. ivjejb35.jar
2. j2cImpl.jar
3. j2ee.jar
4. naming.jar
5. namingclient.jar
6. webcontainer.jar
7. j2c.properties
8. implfactory.properties
Following is the code I am using to get the DataSource:
private DataSource getDataSource(
String jndiName) throws NamingException{
DataSource ds = null;
InitialContext context = null;
try {
Properties prop = new Properties();
prop.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
prop.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:2908");
context = new InitialContext(prop);
ds = (DataSource) javax.rmi.PortableRemoteObject.narrow(
context.lookup(jndiName),
DataSource.class);
} catch (ClassCastException ne) {
//Handle exception
}
return ds;
}