ClassCastException using Websphere as the external JTA manager
search cancel

ClassCastException using Websphere as the external JTA manager

book

Article ID: 294223

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

Symptoms:

This document describes a workaround for a known issue where a ClassCastException can arise when using WebSphere as an external JTA manager with GemFire.

This issue has been reported with WebSphere 7.0.0.25 as the external JTA manager, but may also occur with other versions. Specifically, when the class-loader policy is 'Application' and the class-loader mode is configured as 'PARENT_LAST' the following error may be seen:

==========================================
[warning 2013/12/12 14:32:06.348 EST < Default : 4 > tid=0x7e] JNDIInvoker::doTransactionLookup::Found WebSphere TransactionManager factory class [com.ibm.ws.Transaction.TransactionManagerFactory], but could not invoke its static 'getTransactionManager' method
java.lang.ClassCastException: com.ibm.ws.tx.jta.TranManagerSet incompatible with javax.transaction.TransactionManager
at com.gemstone.gemfire.internal.jndi.JNDIInvoker.doTransactionLookup(JNDIInvoker.java:277)
at com.gemstone.gemfire.internal.jndi.JNDIInvoker.mapTransactions(JNDIInvoker.java:118)
at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.< init >(GemFireCacheImpl.java:627)
at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:607)
at com.gemstone.gemfire.cache.client.ClientCacheFactory.basicCreate(ClientCacheFactory.java:207)
at com.gemstone.gemfire.cache.client.ClientCacheFactory.create(ClientCacheFactory.java:162)
===========================================

Environment


Cause

The root cause is that the javax.transaction API definitions are bundled within the GemFire jar, which is deployed with the webappr, while WebSphere provides its own javax.transaction package. This results in a conflict and the above exception.

Resolution

Currently, there are two options available to avoid this issue:

  1. Explicitly, remove the javax.transaction package from the deployed gemfire.jar file using the following command:
    zip -d gemfire.jar javax/transaction/*
  2. Choose "Class loader for each WAR in application" rather than "Single class loader for application" for the "WAR class loader policy" of the WebSphere instance.