Hi.
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.
THE PROBLEM 1
=============
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
org.apache.naming.factory.TyrexDataSourceFactory
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"
type="tyrex.jdbc.ServerDataSource"/>
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
javax.sql.DataSource.
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
problem.
THE WORKAROUND
==============
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
\src\share\org\apache\naming\factory\TyrexDataSourceFactory:
214 if (ref.getClassName().equals
215 ("tyrex.jdbc.ServerDataSource")) {
216
217 ServerDataSource sds =
218 new
ServerDataSource((javax.sql.XADataSource) ds);
219
220 currentRefAddr = ref.get(DESCRIPTION);
221 if (currentRefAddr != null)
222 sds.setDescription
223
(currentRefAddr.getContent().toString());
224
225 return sds;
226
227 }
228
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 TyrexDataSourceFactory.java 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.
THE PROBLEM 2
=============
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
tyrex.exolab.org, 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-0.9.7.0 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\message.properties. I sent an email to
the tyrex mailing list a couple of weeks ago, asking them if
it possible to quickly release a 0.9.7.1 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
email [EMAIL PROTECTED]
mobile +39 348 1506941 - fax +39 02 700510536
Member of ADI (Italian Ph.D. Association)
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>