-1

i already setup oracle xadatasource in websphere, and i want get datasource by using spring context lookup jndi , exception happen when i start my app : WasjdbcDataSource incompatible with javax.sql.XADataSource. how can i solve this?

Lin Haobo
  • 3
  • 2
  • I don't know WasjdbcDataSource but from you question I suspect It doesn't implement javax.sql.XADataSource. If you can't find any XA Compliant WasjdbcDataSource you can use https://www.atomikos.com/Documentation/NonXaDataSource. – Pascal Leclercq Jul 12 '17 at 07:55
  • @PascalLeclercq thanks – Lin Haobo Jul 13 '17 at 00:03

1 Answers1

1

In a Java EE application server, such as WebSphere Application Server, even though you configure the XA-capable javax.sql.XADataSource, the application (and Spring) should always expect to use it as javax.sql.DataSource. Look in the Spring configuration if there is a way to indicate the expected type of javax.sql.DataSource rather than javax.sql.XADataSource. The XADataSource API is intended only for the application server's own internal use in order to accomplish two-phase commit. The user always interacts with it as javax.sql.DataSource, and gains the ability to enlist multiple resources in a single global transaction.

njr
  • 3,399
  • 9
  • 7
  • you mean i should look jndi as java.sql.datasource and convert it to XAdatasource if spring or manual configuration can. right? – Lin Haobo Jul 12 '17 at 13:23
  • Don't convert/cast it to XADataSource at all. The only place to refer to it as javax.sql.XADataSource is within the WebSphere Application Server definition of the data source (JDBCProvider if traditional WebSphere, or dataSource/jdbcDriver config if Liberty). Everywhere else - Spring, JNDI lookups, resource references... should always refer to and use it as javax.sql.DataSource. – njr Jul 12 '17 at 18:12