geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <djen...@gluecode.com>
Subject Re: Integration of Geronimo modules (Tx / JCA) in Spring
Date Mon, 23 May 2005 19:31:57 GMT

On May 23, 2005, at 12:15 PM, Thierry Templier wrote:

> Hi,
>
> We try to use the Geronimo Transaction Manager and JCA
> Connection Manager in a standalone Spring application
> in order to use JCA connectors and XA Transactions
> without an application server or only in a web
> container (for example Tomcat...).
>
> Although the source code of these modules is really
> great (congratulations for your work), we have had
> some little problems when we try to make work the
> application with them. We work with the 1.0-M3 version
> of Geronimo.
>
> 1°) When we try to use the Geronimo transaction
> manager, we have had a NullPointerException in the
> newTransaction method of the
> ConnectionTrackingCoordinator class. As a matter of
> fact, the oldInstanceContext instance is null whereas
> we do the following thing in the
> TransactionContextManagerFactoryBean class:
>
> this.transactionContextManager.newUnspecifiedTransactionContext();
>
> So we modify the newTransaction method as following:
> public void newTransaction() throws ResourceException
> {
>     InstanceContext oldInstanceContext =
> (InstanceContext) currentInstanceContexts.get();
>     if( oldInstanceContext!=null ) {
>         notifyConnections(oldInstanceContext);
>     }
> }
>
I'll try to describe briefly what's going on here, but it's a somewhat  
complicated subject and I've probably forgotten a few details.

The J2CA spec requires us to support the following (IMO ridiculous)  
scenario:

call into EJB A with user x
A acquires connection with login based on x (such as same name, or  
maybe some group name)
On method exit, A does not close connection but keeps it
call into EJB A with user y
the connection saved in A must still be usable, but must now be  
attached to a physical connection based on y.

In order to keep track of stuff like this, we have an InstanceContext.   
The (ejb, servlet, app client, ...)  container framework is required to  
register the appropriate instance context with the  
ConnectionTrackingCoordinator before allowing the call into the  
instance object.  This is done e.g. in the jetty module  
InstanceContextBeforeAfter and in openejb's  
ConnectionTrackingInterceptor.

If you want to support holding connections open over method calls, you  
should find a way to install such an instance context before control  
gets to the implementation object.  If not, lets talk about removing  
this requirement for use of the geronimo j2ca framework.


> Perhaps have we not make a correct initialization of
> the Transaction Manager module (TransactionManager and
> TransactionContextManager). Here is the code to do
> that:
>
> //Instanciate the Geronimo extended transaction
> manager
> if( this.transactionManagerImpl==null ) {
>     this.transactionManagerImpl=new
> TransactionManagerImpl();
> }
>
> //Select a recovery support
> XidFactory xidFactory=new XidFactoryImpl();
> if( this.transactionLog==null ) {
>     this.transactionLog=new UnrecoverableLog();
> }
> Recovery recovery=new
> RecoveryImpl(this.transactionLog,xidFactory);
>
> //Instanciate the transaction context manager
> this.transactionContextManager=new
> TransactionContextManager(this.transactionManagerImpl,
>
> this.transactionManagerImpl,recovery);
>
> this.transactionContextManager.newUnspecifiedTransactionContext();
>
I think this is ok, but I didn't look too hard :-)

> 2°) We have too an other problem. Geronimo seems to
> work with the NamedXAResource interface (an interface
> which extends the XAResource interface).
> We make some tests with XAPool and we have a
> ClassCastException if we don't wrap the XAResource we
> use in a WrapperNamedXAResource class:
>
> Transaction ntx = this.getTransaction();
> ...
> tx.enlistResource(new
> WrapperNamedXAResource(xacon.getXAResource(),"XAPool"));
>
> Is it possible to use directly XAResource with the
> Geronimo Transaction Manager?
>
no :-)

We need the NamedXAResource in order to be able to do recovery.   
Otherwise there really isn't any way to determine when all the  
XAResources needed for recovering transactions have been started.

Note that if you are using the j2ca framework it will register all the  
XAResources itself and it already supplies the NamedXAResource wrapper.  
  Do you have a plausible use case for an application registering a  
transaction participant itself rather than relying on framework code?

many thanks,
david jencks

> I'll try to make our integration work with the latest
> version of these modules.
> Thanks for your help and your answers,
> Thierry
>
> Take a look at my blog:
> http://templth.blogspot.com/
>
>
> 	
> 	
> 		
> _______________________________________________________________________ 
> _____________
> Le Yahoo! Messenger BETA est arrivé ! : Découvrez les appels audio  
> illlimités et le partage de photos facilité
> Téléchargez cette version sur http://fr.messenger.yahoo.com
>


Mime
View raw message