Wednesday, 7 October 2015

WebSphere Application Server - Variables and Databases

I saw this ongoing issue today: -

[07/10/15 20:34:33:714 BST] 0000008f ConnectionFac E   J2CA0009E: An exception occurred while trying to instantiate the ManagedConnectionFactory class com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource jdbc/Sample : java.lang.reflect.InvocationTargetException

[07/10/15 20:34:33:709 BST] 0000008f J2CUtilityCla E   J2CA0036E: An exception occurred while invoking method setDataSourceProperties on com.ibm.w
s.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource jdbc/Sample : com.ibm.ws.exception.WsException: DSRA0023E: The DataSource implementation class "com.ibm.db2.jcc.DB2XADataSource" could not be found.

[07/10/15 20:34:33:723 BST] 0000008f SystemErr     R com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is java.lang.reflect.InvocationTargetException]]

[07/10/15 20:34:33:728 BST] 0000008f SystemErr     R Caused by: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is java.lang.reflect.InvocationTargetException]

[07/10/15 20:34:33:734 BST] 0000008f SystemErr     R Caused by: com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException: DSRA0023E: The DataSource implementation class "com.ibm.db2.jcc.DB2XADataSource" could not be found.

Caused by: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2XADataSource

This came about because I was using a JDBC Provider and Data Source, both of which I'd created at the scope of the cell: -

Create JDBC Provider

cellID=AdminControl.getCell()

provider=AdminTask.createJDBCProvider('[-scope Cell='+cellID+' -databaseType DB2 -providerType "DB2 Using IBM JCC Driver" -implementationType "XA data source" -name "DB2 Using IBM JCC Driver (XA)" -description "Two-phase commit DB2 JCC provider that supports JDBC 4.0 using the IBM Data Server Driver for JDBC and SQLJ. IBM Data Server Driver is the next generation of the DB2 Universal JCC driver. Data sources created under this provider support the use of XA to perform 2-phase commit processing. Use of JDBC driver type 2 on WebSphere Application Server for Z/OS is not supported for data sources created under this provider. This provider is configurable in version 7.0 and later nodes." -classpath [${DB2_JCC_DRIVER_PATH}/db2jcc4.jar ${DB2_JCC_DRIVER_PATH}/db2jcc_license_cu.jar ] -nativePath [${DB2_JCC_DRIVER_PATH} ] ]')


Create JDBC Data Source

AdminTask.createDatasource(provider, '[-name Sample -jndiName jdbc/Sample -dataStoreHelperClassName com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper -containerManagedPersistence true -componentManagedAuthenticationAlias db2user1 -xaRecoveryAuthAlias -configureResourceProperties [[databaseName java.lang.String SAMPLE] [driverType java.lang.Integer 4] [serverName java.lang.String wasdemo.uk.ibm.com] [portNumber java.lang.Integer 60006]]]')

Whilst I was able to happily test the datasource: -

AdminControl.invoke('WebSphere:name=DataSourceCfgHelper,process=dmgr,platform=dynamicproxy,node=Dmgr,version=8.5.5.5,type=DataSourceCfgHelper,mbeanIdentifier=DataSourceCfgHelper,cell=WASCell,spec=1.0', 'testConnection', '[cells/WASCell|resources.xml#DataSource_1444136343751]', '[java.lang.String]')

my application failed with the above exceptions.

The solution ?

The application, running on the Application Server on the Node, is referencing a cell-scoped JDBC data source using a cell-scoped JDBC provider .... which has a WebSphere Variable - DB2_JCC_DRIVER_PATH - which is only available at the cell-level.

However, that wasn't the problem :-)

When I dug further, I *DID* have an identically named variable, scoped at the node-level: -


Can you see what I did wrong ?

Yes, I had a variable scoped at the node, which trumps the cell, which had a null value.

Once I fixed this: -

AdminConfig.modify('(cells/WASCell/nodes/AppSrv01Node|variables.xml#VariableSubstitutionEntry_1444248288880)', '[[symbolicName "DB2_JCC_DRIVER_PATH"] [description ""] [value "/opt/ibm/WebSphere/AppServer/jdbcdrivers/DB2/ "]]')

everything was lovely again :-)

This was definitely of use: -

as did this: -

No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...