This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Problem with DataSource lookup through java client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with DataSource lookup through java client" Watch "Problem with DataSource lookup through java client" New topic
Author

Problem with DataSource lookup through java client

Makarand Parab
Ranch Hand

Joined: Dec 10, 2004
Posts: 121
Hi
I am doing a look up for Datasource on Websphere from a java client. The code and exception is as follow
I have classes12.jar, cm.jar, j2ee.jar, rt.jar and websphere.jar in my classpath.

Code
****************
private void lookUp()
{
Connection conn = null;
try
{
java.util.Hashtable parms = new java.util.Hashtable();
parms.put( Context.PROVIDER_URL, url );
parms.put( Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

InitialContext ctx = new InitialContext(parms);
System.out.println("InitialContext ctx ::: " + ctx);

Object ref = ctx.lookup("target");

System.out.println("ds ::: " + ref.getClass().getName());

DataSource corrXmlApiHome = (DataSource)PortableRemoteObject.narrow(ref, DataSource.class);

System.out.println(corrXmlApiHome);

conn = corrXmlApiHome.getConnection();
System.out.println("Connection ::: " + conn);


}
catch(Exception e)
{
System.out.println("Exception e " + e.getClass().getName());
System.out.println("Exception e " + e.getMessage());
e.printStackTrace();
}
}

Exception
************************
Exception e com.ibm.ejs.jts.jts.CurrentSet$InitializationError
Exception e not initialized
com.ibm.ejs.jts.jts.CurrentSet$InitializationError: not initialized
at com.ibm.ejs.jts.jts.CurrentSet.self(CurrentSet.java:218)
at com.ibm.ejs.jts.jts.CurrentSet.get_control(CurrentSet.java:265)
at com.ibm.ejs.jts.jts.Current.get_control(Current.java:72)
at com.ibm.ejs.util.tran.Util.getCoordinator(Util.java:13)
at com.ibm.ejs.cm.pool.ConnectionPool.allocateConnection(ConnectionPool.java:686)
at com.ibm.ejs.cm.pool.ConnectionPool.getConnection(ConnectionPool.java:312)
at com.ibm.ejs.cm.DataSourceImpl$1.run(DataSourceImpl.java:129)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.ejs.cm.DataSourceImpl.getConnection(DataSourceImpl.java:127)
at com.ibm.ejs.cm.DataSourceImpl.getConnection(DataSourceImpl.java:102)
at Client.lookUp(Client.java:54)
at Client.main(Client.java:29)

Thanks in Advance

Regards
Makarand Parab
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Doesn't WebSphere have a facility whereby you can run a J2EE client within the client container? The client container would take care of setting all that stuff up for you.


James Carman, President<br />Carman Consulting, Inc.
Makarand Parab
Ranch Hand

Joined: Dec 10, 2004
Posts: 121
HI james
Thanks for responding, I am writing a batch application and this application is outside the Websphere Application Server.The java client exist on c or d drive from where it will interact with the WAS.

Regards
Makarand parab
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
http://www-1.ibm.com/support/docview.wss?rs=180&context=SSEQTP&uid=swg1PQ78401
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with DataSource lookup through java client
 
Similar Threads
Problem!! Oracle datasource in Websphere STUDIO
Help me! About DataSourceFactory
JNDI LOOK up problem for datasource
WebSphere 3.5 Connectio pool ??
IBM Websphere 5 Connection Pool