Atomikos Forum |
|
I am trying to perform a jndi lookup for DB2 database hosted on Websphere 6.1 in the following manner:
Context ctx=new InitialContext(); AtomikosDataSourceBean ds = (AtomikosDataSourceBean) ctx.lookup(dataSourceName); However, encontered the following Exception: java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource incompatible with com.atomikos.jdbc.AtomikosDataSourceBean Does that mean i cannot use the AtomikosDataSourceBean for jndi lookup on websphere? What is the correct method then?
@Torsten:
This is the code i am using now to do the jndi lookup. Context ctx = new InitialContext(); ds = new AtomikosDataSourceBean(); ds.setXaDataSource((XADataSource) ctx.lookup("jdbc/dataSource1")); This causes the following exception: [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource incompatible with javax.sql.XADataSource [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.BusinessEntities.JndiConn.<init>(JndiConn.java:26) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.Servlet.InitialServlet.init(InitialServlet.java:42) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at javax.servlet.GenericServlet.init(GenericServlet.java:256) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:218) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.init(ServletWrapper.java:319) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:412) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3440) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1461) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:118) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873) [3/27/12 11:44:13:292 EDT] 0000004d SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473) which as the 1st line says, is due to WSJdbcDataSource (Websphere's datasource) not being able to be cast to XADatasource. How else should I use the AtomikosDataSourceBean class ?? P.S: this isnt a spring project.I am not using EJB. |