Categories
Java WebSphere

Websphere refuses to start – port conflicts

An error such as:
CORBA.INTERNAL: CREATE_LISTENER_FAILED_4
may occur.

When this error happens, the most likely suspect is actually WebSphere itself. A stray/runaway instance may be running and hogging the ports.

To solve, either switch ports (IBM support page) or just kill the stray WebSphere instances, normally guised as java.exe (as opposed to normal Java applications that use javaw.exe).

Share
Categories
Java WebSphere

Setting up a JNDI data source in WebSphere 6.0/6.1

Yes. I am now one of those, those people who work with WebsSphere.

WebSphere has its way of doing things that is clear or convoluted or both once you wrap your head around it. On my current project we needed to set up a data source, using JNDI on the server. The data source was an Oracle 10g database.
1. Setting up the database drivers
To be truly precise, the first thing you would need to do is get and store a copy of the Oracle driver jar of your choice. Getting the driver is pretty rudimentary, but where to store them and how WebSphere will find them is a separate issue.

Log into WebSphere’s administrative console and from the left navigation menu, choose Environment. Expanded, select WebSphere Variables from the menu, which will list WebSphere’s environment variables. Here, look at the value of the WAS_INSTALL_ROOT variable. The location specified will have a lib directory under it. That will be the location where you would drop the Oracle driver jar file.

Next, on the same or previous screen, select to update the value of ‘Oracle JDBC Driver Path’. In the page that will appear, enter the value ${WAS_INSTALL_ROOT}/lib which is where you saved the Oracle drivers.

2. Set up user credentials for the JNDI database connection

WebSphere stores all user name and password information centrally and does so in a different area of the administrative console. Since your JNDI connection will require a user name and password, you will need to store them in advance as a ‘JAAS J2C Authentication Data’. From the left navigation, click Security and then Secure administration, applications, and infrastructure. In the screen that will appear, expand the Java Authentication and Authorization Service on the right part of the page, and then click on the J2C Authentication Data link.

The next screen will show a list of existing WebSphere identities. Click to add a new one, enter the information for it and click save. Always remember to click save if asked to so your changes will be save to the server’s master configuration.

3. Setting up the JDBC provider

Now, expand the Resources section of the left navigation and click JDBC and then JDBC Providers. According to IBM: “The JDBC provider object encapsulates the specific JDBC driver implementation class for the data sources that you define and associate with the provider.” Therefore, select the appropriate scope from the drop down list and click ‘New’. On the next screen, select the database type, provide type, etc., giving it a name you will understand. On the next screen, point to the driver path we specified in step 1 above. Now we can connect to a database from Oracle. Now to connect to THE database we want to.

4. Creating the data source
Now, go back to the list of available data providers. Click the name of the one you just set up and in the screen that again outlines its properties, click the Data Sources link from the right-hand column.

Note: on WebSphere 6.0 most of the information appears on one screen while in version 6.1 the form is split across multiple screens. The gist of the information below is identical.
On the next screen, click the New button. A new form, this time to specify the data source will appear half pre-populated with the data provider information. Here, specify the JNDI name you would want to access the database with (e.g. jdbc/MyDatabase) and from the bottom drop-down, select the J2C identity you will use to log into the database. Then, enter the URL of the Oracle database using a URL that does not use the user name and password. For example:
jdbc:oracle:thin:@[ip address]:[Oracle port (1521)]:[Oracle database name (orcl)]
Finally, hit the OK or Apply button and test the connection.

If all is well, and on the first try something did probably go wrong, look into the steps above and try again. As bad as it looks, if you know the steps, this is way easier than the average open source maze.

MySQL appendix

To set up a MySQL datasource, be sure to download the driver from the MySQL website and follow the general directions above. The only twist is that MySQL requires you to set up a user-defined JDBC provider. The only thing that makes this different is that you need to use the connection pool driver for MySQL instead of its usual driver. The name of this connection pool driver is:
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource

To specify the database name, port and IP address you need to specify custom properties for the data source. This DevX article has the complete details.

Update (Oct. 15, 2007):
I tried setting up the JNDI data source using the new version of the MySQL connector, and it did not go so well, giving me odd errors. Version 3.x seems stable enough and works.

Share
Share