File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes Access Server's Datasource from standalone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Access Server Watch "Access Server New topic

Access Server's Datasource from standalone

Sunil Dumpala

Joined: Jul 28, 2005
Posts: 29

Earlier I posted the below topic in IDE section of javaranch. Haven't got any response. Since this topic is related to WSAD 5.1 I have posted it here to see if I could get any response.

I coded a simple HelloWorld program by creating a java project in WSAD. I added a datasource in my Test Server in WSAD. All I was trying to do was access the datasource using JNDI. Standard way of soing it (if it were a jsp or any J2EE application ) would be as follows

javax.naming.InitialContext ctx = new javax.naming.InitialContext();
DataSource ds = (javax.sql.DataSource) ctx.lookup("jdbc/UASSUNILLOCALds");

For some reason Server was trying to read WEB-INF/config/ file and was throwing a FileNotFoundException. I found a similar posting on the net where someone suggested to change the code as follows

1. Hashtable env = new Hashtable();
3. javax.naming.InitialContext ctx = new javax.naming.InitialContext();
4. DataSource ds = (javax.sql.DataSource) ctx.lookup("jdbc/UASSUNILLOCALds");

And included whole bunch of jar files such as naming.jar, namingclient.jar, wssec.jar, lmproxy.jar, sas.jar, implfactory.jar, ecutils.jar and a file into the classpath.Now I am able to get the context but I am getting ClassCastException on line 4. The reason is ctx.lookup is returning me the javax.naming.Reference object of DataSource "jdbc/UASSUNILLOCALds". I am using JDK 1.3 and included the classes12.jar oracle driver files.

I need to create a standalone java file which would be run as batch job. If I can access the datasource through JNDI then I could have placed the file as part of bigger application and use the server connection pools etc., But since this didn't work out and I am running out of time, I am planning to use iBatis. If anybody has any suggestions on how to get the issue rectified or any comments on the usage of iBATIS please let me know. I am new to iBTAIS too so not sure if that would work out or not.

Prasanth James M J

Joined: Jun 06, 2003
Posts: 5
Hi Sunil,
Donno if this will solve your problem on 5.1; but I was facing the same problem with WS V6, datasource V5 and I just managed to solve it. Its basically a problem of missing jars in the client classpath. I have mentioned the full list of jars required in this blog -!5A9C105A65B799CB!119.entry

Give it a try!
Russell Ray
Ranch Hand

Joined: Apr 25, 2005
Posts: 116

Thank you VERY MUCH for posting your efforts. You saved me MORE than two days......

Russell Ray
Ranch Hand

Joined: Apr 25, 2005
Posts: 116
Okay, I am working through most of this issue within WSAD 5.1.1 and WAS 5.0.

What I am doing is going direct to the DataSource using the jndi.

I am able to get a POJO client running within WSAD by adding the following jars to the classpath:

When I move the client outside WSAD (updating the classpath with the above jars/properties) I get the below error:

Based upon my observations, I think I have covered the above I am at a lost why this does not work.

When I go search for the implfactory.jar, I do not see it.

Any help would be greatly appreciated.

Prasanth James M J

Joined: Jun 06, 2003
Posts: 5
Now, shift to IBM JRE on your client JVM classpath and run the code again. it will work. Reason!? the client has some lookup dependencies with the IBM JRE Orb classes. Though, this is supposed to work with Sun JRE if you have the ibmorb.jar in your classpath, i could not figure it out. But it works with IBM JRE libs.!!
Jose Coqueiro

Joined: Nov 15, 2008
Posts: 28
Hello All,

opening it back, i've done what you guys said, but I'm getting the following error, can someone please help?

I agree. Here's the link:
subject: Access Server's Datasource from standalone
It's not a secret anymore!