Hi did you investigate http://www-01.ibm.com/support/docview.wss?uid=swg21429116 or different driver versions (seems some have a fix for it)?
Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2017-02-13 17:45 GMT+01:00 David Stiles <[email protected]>: > We are in the process of porting a large and mature application from > WebLogic > to TomEE. The application currently supports DB2, Oracle, SQL Server and > PostgreSQL databases. The application also has a requirement to access > multiple datasources within a single transaction. This currently works with > WebLogic and with all supported databases. It also works in the application > ported to TomEE with Oracle, SQL Server and PostgreSQL, but we have > encountered a problem when running with DB2. > > The problem we have observed is a failure to enlist the datasource that is > accessed second in the transaction. Once a connection is obtained from > DataSource.getConnection(), the first use of the connection, regardless of > the method called (e.g. prepareStatement(), getAutoCommit(), close()), > results in the exception shown below. > > It is unclear to us where the actual problem is. Is it our configuration or > usage of TomEE or our datasources? Is it a problem with TomEE? Is it a > problem with DB2 or the DB2 JDBC driver? The problem has been reproduced > with TomEE 7.0.1 and TomEE 7.0.2, with DB2 10.5 and 11.1, and with both the > DB2 10.5 FP8 JDBC 4.0 driver and DB2 11.1 FP1 JDBC 4.0 driver. We have > attempted to investigate the DB2 error reported in the exception, but have > been unable to find any relevant information. > > We have put together a simple test application that demonstrates the > problem > and is contained in the attached package file multids.zip > <http://tomee-openejb.979440.n4.nabble.com/file/n4681087/multids.zip> . > One > thing that the test application demonstrates is that this is not a general > problem when accessing two datasources within a single transaction when > only > one of the datasources is for DB2 (i.e. when the DB2 JDBC driver is not > used > for both datasources). It appears to only be a problem when both > datasources > are using the same DB2 JDBC driver. This seems to suggest the problem is > with the driver, however again, the same use case works with WebLogic. That > seems to suggest the problem is with TomEE, but the same use case works > with > other databases. > > One other use case that was tested as an experiment during development of > the attached test application is also accessing two datasources within a > single transaction, but from within an embedded TomEE instance instead of > remotely. In this case the same problem occurs with DB2, but additionally, > a > similar problem occurs with Oracle, which does not occur in the remote > TomEE > case. The attached test application demonstrates both the embedded and > remote TomEE failures and with both DB2 and Oracle. Other database types > were not tested in the embedded TomEE case. > > An example exception as seen with DB2 in the remote TomEE case: > > 09-Feb-2017 16:48:22.347 WARNING [http-nio-8080-exec-1] > org.apache.geronimo.transaction.manager.TransactionImpl.enlistResource > Unable to enlist XAResource com.ibm.db2.jcc.t4.ec@4278c5cf, errorCode: -4 > com.ibm.db2.jcc.am.XaException: [jcc][t4][10401][12066][4.19.66] XA > exception: XAER_NOTA ERRORCODE=-4228, SQLSTATE=null > at com.ibm.db2.jcc.am.kd.c(kd.java:524) > at com.ibm.db2.jcc.am.kd.c(kd.java:548) > at com.ibm.db2.jcc.t4.ec.a(ec.java:2100) > at com.ibm.db2.jcc.t4.ec.a(ec.java:2346) > at com.ibm.db2.jcc.t4.ec.start(ec.java:1938) > at > org.apache.geronimo.transaction.manager.TransactionImpl.enlistResource( > TransactionImpl.java:202) > at > org.apache.openejb.resource.jdbc.managed.local.ManagedConnection.invoke( > ManagedConnection.java:134) > at com.sun.proxy.$Proxy106.prepareStatement(Unknown Source) > at com.opentext.multids.DbActions.insert(DbActions.java:61) > at com.opentext.multids.DbActions.insert(DbActions.java:85) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > 62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke( > DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.apache.openejb.core.interceptor.ReflectionInvocationContext$ > Invocation.invoke(ReflectionInvocationContext.java:205) > at > org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed( > ReflectionInvocationContext.java:186) > at > org.apache.openejb.monitoring.StatsInterceptor.record( > StatsInterceptor.java:181) > at > org.apache.openejb.monitoring.StatsInterceptor.invoke( > StatsInterceptor.java:100) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > 62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke( > DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.apache.openejb.core.interceptor.ReflectionInvocationContext$ > Invocation.invoke(ReflectionInvocationContext.java:205) > at > org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed( > ReflectionInvocationContext.java:186) > at > org.apache.openejb.core.interceptor.InterceptorStack. > invoke(InterceptorStack.java:85) > at > org.apache.openejb.core.stateful.StatefulContainer.businessMethod( > StatefulContainer.java:690) > at > org.apache.openejb.core.stateful.StatefulContainer. > invoke(StatefulContainer.java:377) > at > org.apache.openejb.core.ivm.EjbObjectProxyHandler. > synchronizedBusinessMethod(EjbObjectProxyHandler.java:265) > at > org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod( > EjbObjectProxyHandler.java:260) > at > org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke( > EjbObjectProxyHandler.java:89) > at > org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke( > BaseEjbProxyHandler.java:347) > at > com.opentext.multids.DbActions$$LocalBeanProxy. > insert(com/opentext/multids/DbActions.java) > at org.apache.jsp.index_jsp._jspService(index_jsp.java:309) > at org.apache.jasper.runtime.HttpJspBase.service( > HttpJspBase.java:70) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) > at > org.apache.jasper.servlet.JspServletWrapper.service( > JspServletWrapper.java:443) > at org.apache.jasper.servlet.JspServlet.serviceJspFile( > JspServlet.java:385) > at org.apache.jasper.servlet.JspServlet.service(JspServlet. > java:329) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( > ApplicationFilterChain.java:230) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter( > ApplicationFilterChain.java:165) > at org.apache.tomcat.websocket.server.WsFilter.doFilter( > WsFilter.java:52) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( > ApplicationFilterChain.java:192) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter( > ApplicationFilterChain.java:165) > at org.apache.openejb.server.httpd.EEFilter.doFilter( > EEFilter.java:65) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( > ApplicationFilterChain.java:192) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter( > ApplicationFilterChain.java:165) > at > org.apache.catalina.core.StandardWrapperValve.invoke( > StandardWrapperValve.java:198) > at > org.apache.catalina.core.StandardContextValve.invoke( > StandardContextValve.java:108) > at org.apache.tomee.catalina.OpenEJBValve.invoke( > OpenEJBValve.java:44) > at > org.apache.catalina.authenticator.AuthenticatorBase.invoke( > AuthenticatorBase.java:472) > at > org.apache.catalina.core.StandardHostValve.invoke( > StandardHostValve.java:140) > at > org.apache.catalina.valves.ErrorReportValve.invoke( > ErrorReportValve.java:79) > at > org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke( > OpenEJBSecurityListener.java:97) > at > org.apache.catalina.valves.AbstractAccessLogValve.invoke( > AbstractAccessLogValve.java:620) > at > org.apache.catalina.core.StandardEngineValve.invoke( > StandardEngineValve.java:87) > at > org.apache.catalina.connector.CoyoteAdapter.service( > CoyoteAdapter.java:349) > at > org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784) > at > org.apache.coyote.AbstractProcessorLight.process( > AbstractProcessorLight.java:66) > at > org.apache.coyote.AbstractProtocol$ConnectionHandler.process( > AbstractProtocol.java:802) > at > org.apache.tomcat.util.net.NioEndpoint$SocketProcessor. > doRun(NioEndpoint.java:1410) > at > org.apache.tomcat.util.net.SocketProcessorBase.run( > SocketProcessorBase.java:49) > at > java.util.concurrent.ThreadPoolExecutor.runWorker( > ThreadPoolExecutor.java:1142) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run( > ThreadPoolExecutor.java:617) > at > org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run( > TaskThread.java:61) > at java.lang.Thread.run(Thread.java:745) > > > > -- > View this message in context: http://tomee-openejb.979440. > n4.nabble.com/Problem-with-accessing-multiple-DB2-datasources-within-one- > transaction-using-TomEE-tp4681087.html > Sent from the TomEE Users mailing list archive at Nabble.com. >
