tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabrizio Giudici" <>
Subject Tyrex transactions: a workaround
Date Sat, 02 Feb 2002 21:34:14 GMT

After some investigations about tyrex problems with
transactions and messing up with tyrex and catalina
sources I was able to analyze the problem (actually
two different bugs) and to find a quick and dirty workaround.


Tyrex defines, among others, two kinds of DataSources:

- tyrex.jdbc.xa.EnabledDataSource
  is not aware of pooling and it does not register
  its connections with the transaction manager
- tyrex.jdbc.ServerDataSource
  is aware of pooling and registers its connections
  with the transaction manager

Guess what, it happens that tomcat 4 is giving us
the FORMER DataSource, so transactions are not working
(and pooling neither).

The factory for Tyrex datasources is
which lives in %CATALINA_HOME%/lib/naming-factory.jar.

The logics inside the factory create a
tyrex.jdbc.ServerDataSource only if the resource class
type is explicitly set to tyrex.jdbc.ServerDataSource.

It appears that the problem should be solved by properly
setting the 'type' attribute of Resource in server.xml:

<Resource name="jdbc/adi" auth="Container"

Unfortunately this does not work, and I believe this is a
tomcat bug (in facts, try to set 'type' to "I.DO.NOT.EXIST"
and you'll discover that catalina doesn't notice it).
The Resource gets always bound in JNDI with type

I haven't checked the bug archive yet to find if this is
a known bug; in the meantime I found a workaround that
works. I consider it a quick-and-dirty fix to help us
working with our applications until apache staff fixes the


Unfortunately we have to patch catalina :-(
Download catalina sources (I worked with 4.0.2-b2 but it
works well also with 4.0.1) and edit

 214                     if (ref.getClassName().equals
 215                         ("tyrex.jdbc.ServerDataSource")) {
 217                         ServerDataSource sds =
 218                             new
ServerDataSource((javax.sql.XADataSource) ds);
 220                         currentRefAddr = ref.get(DESCRIPTION);
 221                         if (currentRefAddr != null)
 222                             sds.setDescription
 225                         return sds;
 227                     }
 229                     return ds;

REMOVE LINES 214,215 and 227, 228, 229 so that the ServerDataSource is
always created.

To compile the code, if you don't want to do a complete build of
catalina, do the following:

1. get the %CATALINA_HOME%\server\lib\catalina.jar
2. compile including catalina.jar, servlet.jar
   and jdbc2_0-stdext.jar in the classpath
3. replace the TyrexDataSourceFactory.class in catalina.jar with the
   compiled one.


A this point, you will find that every transaction operation
fails with catalina complaining about a org.omb.corba.XXX
missing class. The problem is that tyrex depends on a couple
of corba classes (even if you don't use them working locally).
To solve this, you must download tyrex distribution from, find ots.jar and add it into
%CATALINA_HOME%\common\lib. At this point I was succesful in
having my transaction works!!!

Summing up, the bugs are:

  1. the type attribute for Resource does not work
  2. apache should include ots.jar with its distribution

Neither is a tyrex bug.

PS. There is a third, small problem that you can live with.
tyrex- misses a message resource file, so you will find
a complaining warning (and in case of problems you won't get
the correct diagnostic). If you want to fix it, download tyrex
sources from exolab, and add to the .jar the file
tyrex\utils\resources\ I sent an email to
the tyrex mailing list a couple of weeks ago, asking them if
it possible to quickly release a with the missing file
added... but I got no reply.

If you manage in following my instructions and the thing
works for you, please let me know (to confirm my analisys).
If my analisys gets confirmed, I will post a message to the
tomcat-dev m.l. (and/or register a bug with the damn bug tracking
thing if I understand how to use it :-)

Fabrizio Giudici, Ph.D. - Senior Consultant
Java(TM) Architect, Mentor, Senior Writer
mobile +39 348 1506941 - fax +39 02 700510536
Member of ADI (Italian Ph.D. Association)

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message