Monday 23 July 2018

WebSphere Application Server - Testing JDBC connections via Jython and the EJBTimer

As part of a recent engagement, I'd written a simple Jython script to test WAS -> database connections: -

cellID = AdminControl.getCell()
cell=AdminConfig.getid( '/Cell:'+cellID+'/')
for dataSource in AdminConfig.list('DataSource',cell).splitlines():
 print dataSource
 AdminControl.testConnection(dataSource)


However, when I ran this against an IBM Business Process Manager Standard 8.6 environment, I saw this: -

DefaultEJBTimerDataSource(cells/PCCell1/applications/commsvc.ear/deployments/commsvc|resources.xml#DataSource_1228749623069)
WASX7017E: Exception received while running file "/mnt/Scripts/testDataSource.jy"; exception information: com.ibm.websphere.management.exception.AdminException
javax.management.MBeanException
java.sql.SQLException: java.sql.SQLException: Database '/opt/ibm/WebSphereProfiles/AppSrv01/databases/EJBTimers/AppClusterMember1/EJBTimerDB' not found. DSRA0010E: SQL State = XJ004, Error Code = 40,000

which was an annoyance, as I'm not actively using the EJBTimer datasource.

As ever, the solution was simple, rather than testing ALL datasources within the cell, I changed the script to only test the datasources that are specifically part of the BPM Deployment Environment i.e. those that are scoped at cluster level.

cellID = AdminControl.getCell()

cell=AdminConfig.getid( '/Cell:'+cellID+'/')
cluster=AdminConfig.getid("/ServerCluster:AppCluster/")
for dataSource in AdminConfig.list('DataSource',cluster).splitlines():
 print dataSource
 AdminControl.testConnection(dataSource)

cluster=AdminConfig.getid("/ServerCluster:AppCluster/")
for dataSource in AdminConfig.list('DataSource',cluster).splitlines():
 print dataSource
 AdminControl.testConnection(dataSource)

cluster=AdminConfig.getid("/ServerCluster:AppCluster/")
for dataSource in AdminConfig.list('DataSource',cluster).splitlines():
 print dataSource
 AdminControl.testConnection(dataSource)

For a BPM Standard environment, this is good enough………

Also, for the record, it's possible to see the EJBTimer datasources within the WAS Integrated Solutions Console: -




which is nice.

No comments:

Visual Studio Code - Wow 🙀

Why did I not know that I can merely hit [cmd] [p]  to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub...