ClassCastException occurs during JNDI lookup of a data source in WebSphere Application Server V5
 Technote (troubleshooting)
 
Problem(Abstract)
In WebSphere® Application Server V5, the following exception might be issued during the JNDI™ lookup of a data source:

"java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource"


This might occur only when using an XA-enabled data source.
 
Cause
The application code that performs the JNDI lookup is causing the problem. The following application code is casting the object returned by the JNDI lookup to javax.sql.XADataSource, instead of javax.sql.DataSource:

XADataSource ds = (XADataSource) ctx.lookup(jndiDataSource);
 
 
Resolving the problem
Change the application to the following to cast the object returned by the JNDI lookup to javax.sql.DataSource:
DataSource ds = (DataSource) ctx.lookup(jndiDataSource);

The WebSphere Application Server Relational Resource Adapter wrappers the XADataSource; therefore, there is no need for the application to use the javax.sql.XADataSource class. Applications should use only the javax.sql.DataSource. All that is needed to use an XA data source is to configure the data source under an XA-enabled JDBC Provider in the Admin Console.
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > DB Connections/Connection Pooling
Operating system(s): Windows
Software version: 5.1.1
Software edition:
Reference #: 1179378
IBM Group: Software Group
Modified date: May 12, 2005