After studying the jboss-sources, I was able to find a workaround. If I put the following call at the beginning of the main()-Method of the client, everything works fine:
The reason is that the begin()-method of org.jboss.tm.usertx.client.ClientUserTransaction calls the no-argument constructor InitialContext() to retrieve a UserTransactionSessionFactory. For this to work, the above shown system properties have to be set.
My follow-up question is: Is this a bug or a feature, i.e. should every client (who uses a UserTransaction) have to set these properties? And if so, did I just overlook it, or is this not documented? Or is there a more elegant way to make it work?
use the jndi.properties files in your client classpath
We want to use a user transaction in a web application which should be able to run both inside jboss (.ear) or on a separate web server machine (tomcat).
In the latter configuration, we have got the same problem: passing the JBoss properties to the InitialContext which does the UserTransaction lookup is not enough: utx.begin() then fails, thus the properties must be set as System properties first.
However, we do not want to put jndi.properties that point to JBoss into the classpath of tomcat itself (as far as I can remember that conflicts with the tomcat internal JNDI use).
Is there any other choice to get utx.begin() working?
Or is this a bug in the UserTransaction code (we are using JBoss 3.2.1)?