Issue Details (XML | Word | Printable)

Key: JDBC-344
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Mark Rotteveel
Reporter: Sascha Horn
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jaybird JCA/JDBC Driver

FBXADataSource closes ResultSet in managed transaction

Created: 05/Mar/14 07:28 AM   Updated: 07/May/17 12:32 PM
Component/s: None
Affects Version/s: Jaybird 2.2.3, Jaybird 2.2.4
Fix Version/s: Jaybird 2.2.5, Jaybird 3.0.0

Environment: Ubuntu 12.4 64bit, JBoss-EAP-6.2, FirebirdSS-2-5-1, Jaybird-2.2.3/2.2.4 (FBXADataSource)
Issue Links:
Relate
 

Sub-Tasks  All   Open   

 Description  « Hide
We are using a FBXADataSource in a container managed bean in JBoss Application Server.

In this bean we have a method opens a resultset and iterates through the records.
for every record an other statement executes a update.
When we try to access the record (e.g. resultset.getString(1) ) the following exception occurs:

org.firebirdsql.jdbc.FBSQLException: The resultSet is closed
    at org.firebirdsql.jdbc.AbstractResultSet.getField(AbstractResultSet.java:661)
    at org.firebirdsql.jdbc.AbstractResultSet.getField(AbstractResultSet.java:644)
    at org.firebirdsql.jdbc.AbstractResultSet.getString(AbstractResultSet.java:584)
    at org.jboss.jca.adapters.jdbc.WrappedResultSet.getString(WrappedResultSet.java:1360)
    at de.procar.ecaros2.server.ItemModuleBean.deleteDeletableItemStockLocationAllocations(ItemModuleBean.java:10271)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
    at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:272)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:339)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:238)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:79)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.security.AuthorizationInterceptor.processInvocation(AuthorizationInterceptor.java:122)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:81)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.component.interceptors.EjbExceptionTransformingInterceptorFactories$1.processInvocation(EjbExceptionTransformingInterceptorFactories.java:65)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
    at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
    at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.invokeMethod(MethodInvocationMessageHandler.java:329)
    at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.access$100(MethodInvocationMessageHandler.java:70)
    at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler$1.run(MethodInvocationMessageHandler.java:203)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)

I googled a bit...
The solution should be to use setautocommit(false), but this is not
possible in an container managed transaction.

as a workarround i use setDefaultResultSetHoldable(true).
In my opinion the result set may not be closed within an managed
transaction, because commit and rollback should be invoked from the
managed transaction.


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Rotteveel added a comment - 01/Apr/14 07:15 PM
I have been able to reproduce this. The problem is that while the FBManagedConnection participates in a distributed transaction, the FBConnection somehow still thinks it is in a local transaction in auto commit. Looking at the code history this problem was introduced by commit https://sourceforge.net/p/firebird/code/56009/ (specifically the changes in AbstractConnection and FBManagedConnection).

That code makes deliberate changes to the initialization of the transaction coordinator for a managed connection, making it initially a local coordinator with autocommit. I will also need to test if this problem was hidden until the introduction of the new datasources in org.firebirdsql.ds, or that the old implementation org.firebirdsql.pool exhibits the same problem (it obtains the XA connection in a slightly different way).

Mark Rotteveel added a comment - 01/Apr/14 07:19 PM
Problem could also be caused by https://sourceforge.net/p/firebird/code/56277/

Mark Rotteveel added a comment - 05/Apr/14 10:45 AM - edited
By resetting the 'managedEnvironment' property of the FBConnection in the start() and end() methods of the managed connection the transaction coordinator is correctly set and this works ok, however this runs into another problem with a rollback that happens as part of the 'return connection to pool' which I will need to investigate further.

Mark Rotteveel added a comment - 07/Apr/14 02:35 PM
Issue has been fixed in Jaybird 2.2.5 (to be released next week).

A more thorough fix will be made in Jaybird 3.0 as there is a situation when using the JCA resource adapter (instead of an XADataSource) with connection sharing enabled where this fix will not work; this however requires a more thorough rework of the code. See JDBC-346.