Friday, August 06, 2004

Websphere


Been evaluating Websphere as an alternative to Weblogic... it's actually been quite good going. Have configured a JDBC datasource in a reasonable amount of time - the interface is quite helpful and intuitive. Having configured JDBC on Weblogic and Tomcat before, and having some nightmares getting it absolutely correct, Websphere was OK. This may be because I have configured it on other app servers before and know the pitfalls. The main difference with Websphere was that rather than specifying the database login together with the DataSource definition, you have to configure a "J2C Authentication Data" entry (under "JAAS Configuration" in the Administrator tool - or it will be in the "Related Items" box at the bottom of the DataSource configuration page), specifying the userid and password. Then (having saved that new entry) you have to configure the datasource to use that login using the Component-managed Authentication Alias (or Container-managed Authentication Alias, depending on how your resource is configured... not sure how to do this at the moment).

The first thing I found is that the trial version of Websphere doesn't have a directory specified for an Oracle driver. It looks like it only has access to a Cloudscape driver by default. But by manually amending the variables.xml file in C:/Program Files/WebSphere/AppServer/config/cells//node// to add a value for ORACLE_JDBC_DRIVER_PATH (I just set it to "${WAS_INSTALL_ROOT/lib}"), and then put the ojdbc14.jar file in the C:/Program Files/WebSphere/AppServer/lib directory, and restarted the server.

Restarting the server I found I had to be careful about. I seemed to get my initial installation screwed up and I could stop/start the server. After a few retried reinstalls (which seemed to hang during the installation program), I managed to get a successful reinstall and then used the Launchpad program to start/stop the server. You appear to be also able to do that via the startServer.bat etc. files in the bin directory, but if you stick to the Launchpad you get more info about what's going on. I haven't bothered to look into the best way to do this... :)

The Oracle driver configuration was OK. I chose the XA-enabled Oracle driver (mainly because I had read somewhere that you may run into problems using Hibernate (which is my O/R mapping layer) with transactions disabled. So just to be safe went for XA.
But NB! Having tested my app with the XA driver, I found that it didn't work. Every change to the database got rolled back. So I decided that I must've got the wrong end of the stick with the XA driver, and reverted to the regular Oracle driver!

The driver URL took - as usual - a bit of tweaking, but the format expected by the Websphere Oracle driver appears to be along the lines of:

jdbc:oracle:thin:@hostname:port:sid

fill in hostname, port and sid as appropriate
NB as ever: be careful of what the SID is - it is elusive. Ask a DBA!

I always have qualms about how to configure the JNDI name, but in the Administrator Console, the (quite helpful) notes seem to be fairly explicit that if you just specify a name on its own, it will be prefixed with jdbc/ in the JNDI tree. E.g. "ScoobyDB" will be looked up by "jdbc/ScoobyDB".

Specifying the URL, the J2C login, and leaving all the other properties as defaults, I just hit "Test Connection" and it worked fine.

Labels: