Hi Guido,

we can try to release the used connection on PB.close() call instead of
Synchronization#beforeCompleation.

In PBFSyncImpl line 227 the close() method of PBImpl is overridden. If we are in local-tx we don't really close the used PB handle and thus do not release the used connection (it's done in #beforeCompleation).

To do so we have to make PB.isInTransaction method independed from ConnectionManager.isInLocalTransaction method. After that we can release the used connection (via connectionManager) in PBSyncImpl.close method and keep PBSyncImpl still in PB-tx.

Currently I'm busy with other OJB stuff, but I will try this ASAP. Are you willing to test my changes or do you want to start this refactoring by your own?

regards,
Armin

Guido Beutler wrote:
Hi Armin,

sorry for the delay!
Because nobody else had an answer I spent some time to get closer to the problem.
After that I posted my question at jboss. Here's the thread:


http://www.jboss.org/index.html?module=bb&op=viewtopic&t=49041

I don't know if I am allowed to repost the answer here (copyrights etc. )
Please use the link above. I'm curious about the replies here.

best regards,

Guido

Armin Waibel wrote:

Hi Guido,

>
> Any ideas what's going on there?

I only answer to say "No, I don't have a clue".

I assume (maybe I'm completely wrong ;-)) that JBoss has problems in handling the connections/DataSources associated with the running tx in a proper way. Your direct connection instance will be associated with the suspended tx, within the new tx OJB lookup a new connection, do all work and close the connection. It seems that the used connection is not vaild in jboss TxConnectionManager...bla, bla

Reached the line count for a "do my best answer" ;-)

regards,
Armin

Guido Beutler wrote:

Hello,

I've got a strange problem with RC6 at JBoss 3.2.3.

I've got a statefull and a stateless session bean. The stateless session bean contains all OJB stuff.
The statefull facade accesses some tables via JDBC directly.
That stateless session OJB bean has transaction attribute RequiresNew.
The facade runs with Required.
Both ejb's are container managed.


If a method allocates a JDBC Connection from data source and then access the OJB EJB the following
exception is thrown.


java.lang.IllegalStateException: Trying to return an unknown connection2! [EMAIL PROTECTED]
at org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:330)


at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.connectionClosed(TxConnectionManager.java:539)

at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.closeHandle(BaseWrapperManagedConnection.java:296)

at org.jboss.resource.adapter.jdbc.WrappedConnection.close(WrappedConnection.java:117)

at org.apache.ojb.broker.util.WrappedConnection.close(WrappedConnection.java:124)

at org.apache.ojb.broker.util.pooling.ByPassConnection.close(ByPassConnection.java:64)

at org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.releaseConnection(ConnectionFactoryAbstractImpl.java:79)

at org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.releaseConnection(ConnectionManagerImpl.java:286)

at org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl$PersistenceBrokerSyncImpl.beforeCompletion(PersistenceBrokerFactorySyncImpl.jav

a:177)
at org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl$TransactionBox.beforeCompletion(PersistenceBrokerFactorySyncImpl.java:329)


at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1308)

at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:347)
at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:398)


at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:325)

at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)


at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)


at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)

at org.jboss.ejb.Container.invoke(Container.java:700)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)


at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)


at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)

at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)


at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)

I've got 2 workarounds.

1) If I change RequiresNew at the OJB EJB into Required the problem disappears.
2) If the facade does no access a JDBC connection the problem disappears too.


Any ideas what's going on there?

best regards,

Guido

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to