I apologise if I say something stupid here since I have no experience in EJB. I have a standalone java program that reads an excel workbook, converts it to XML and then inserts the XML data into database. Now I have been able to connect to the Oracle database using thin driver and URL. The client has Webspeher running on the machine where this standalone application would reside (note that the app would *not* be deployed on WAS, it would be on the same *machine*). Since the App server already has a pool to the same database I want to use to use the same using JNDI. How can I use the JNDI? My code looks something like this:
Currently the code is on my machine while the WAS is running on some other machine on our LAN. I am getting error javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory probably beacuse I do not have the classes for JNDI here on my machine. My questions are: (1) Is it possible for a stand-alone java program to connect to a remote database using JNDI? (2) If yes does the program need to have the jar containing the "WsnInitialContextFactory" on client machine as well? (3) Should this application be put somewhere inside folder of WAS which are in classpath (say bin or something), will then only it run? I would really appreciate your replies. Thanks for your valuable time.
Yes, you will need to refer to some of the WebSphere JARs. You don't have to put your app in the same directory as WebSphere, just make sure the JARs are on the client's classpath. One extra ponter to save you a lot of time: If your app server is running using the IBM JRE, make sure th client does as well. If you mix the IBM and SUN JRE's for RMI work they fail to communicate. Dave
To test things I copied my application folder inside the bin sub-folder on WAS application folder. I added the required jar (ns.jar) in application's classpath but now I am getting a NullPointerException when I do a lookup as under.
Also are there any good tutorials on using the "File System Context" for JNDI Lookup? Thanks a lot again.
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss