jQuery in Action, 3rd edition
The moose likes Websphere and the fly likes JNDI look up for datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "JNDI look up for datasource" Watch "JNDI look up for datasource" New topic

JNDI look up for datasource

Amarakunthy Cox

Joined: Apr 23, 2004
Posts: 2

In the above code, once I execute it I get this error:
Exception Class =
Exception Stack =
java.lang.reflect.InvocationTargetException: javax.naming.NoInitialContextException: Cannot instantiate class: com.microsoft.jdbc.sqlserver.SQLServerDataSource. Root exception is java.lang.ClassNotFoundException: com.microsoft.jdbcx.sqlserver.SQLServerDataSource
I am trying to use Websphere 4.0 connection pooling feature using Microsoft SQL Server drivers.
I've created the jndi/datasource and set the classpath using Websphere's interface; used Websphere's "Test Connection" feature and it has passed.
I've checked that the datasource file that the error is indicating is in the *.jar. I've also tried another test by adding the system environment variable to point to the *jars, but still getting the same error.
Any help would be appreciated.

(Code tags added by Michael Morris)
[ April 23, 2004: Message edited by: Michael Morris ]
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Where is this client getting called from? If it is a client outside of the container, you will still need to make sure that the DataSource class is part of the classpath. Other than that, I haven't a clue.

Amarakunthy Cox

Joined: Apr 23, 2004
Posts: 2
All the driver's *.jar files are set on the system environment variable. I have sat down and tried every place possible that I can think of and still the same problem.
Thanks for the suggestion though. Still hammering away ....
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
The problem lies in your code. You don't specify the Datasource class as the InitialContext factory, you specify the InitialContext factory class instead!
The datasource class is specified when you set up the datasource in the admin screen. I STRONGLY suggest you take a look at the Infocenter documentation on setting up datasources. Also take a look at the WebSphere 4.0 programming handbook redbook for information on what class to use when calling an InitialContext.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
I agree. Here's the link: http://aspose.com/file-tools
subject: JNDI look up for datasource
It's not a secret anymore!