All Ant commands are to be executed from the examples/basic/ directory of a JOTM distribution (examples won't work from JOTM source directory).
The basic example is a very simple example showing how to use a Transaction Manager. The client application (Trivial class) looks up the UserTransaction. Then it makes two transactions:
To set up this example, you'll need:
To compile the example, in the examples/basic/ directory, type
$ ant compile
$ export JOTM_HOME=<JOTM_distribution_directory>To run the example, you have to be in the examples/basic/ directory.
There are two commands to run the example:
$ ant run.rmi.jrmp $ ant run.rmi.iiop
The first one assumes that JOTM is accessible through RMI/JRMP and
that a RMI registry is running on its default port (i.e. 1099).
The second one assumes that JOTM is accessible through RMI/IIOP and
that a CORBA name server is running on port 19751.
Both also assume that the UserTransaction object is
accessible on JNDI with the name ``UserTransaction''.
It has to be noted that these two targets are using the same class, Trivial. They just differ in their settings: one is for RMI/JRMP communication whereas the other is a pure RMI/IIOP client.
$ rmiregistry & $ $JOTM_HOME/bin/jotm.sh start -u UserTransaction & $ ant run.rmi.jrmp
(by default JOTM is configured to run on RMI/JRMP so you don't have to modify ../../config/rmi.properties file to run example on it).
Then type
$ tnameserv -ORBInitialPort 19751 & $ $JOTM_HOME/bin/jotm.sh start -u UserTransaction & $ ant run.rmi.iiop
Then type
$ tnameserver -ORBInitialPort 19751 & $ rmiregistry & $ java -jar ../../lib/jotm.jar -u UserTransaction &
Finally you can acces JOTM on both RMI/JRMP or RMI/IIOP
$ ant run.rmi.jrmp $ ant run.rmi.iiop $ ant run.rmi.jrmp $ ...
$ ... $ $ [java] create initial context $ [java] lookup UserTransaction at : UserTransaction $ $ [java] a simple transaction wich is committed: $ [java] - initial status : STATUS_NO_TRANSACTION $ [java] - after begin status : STATUS_ACTIVE $ [java] - after commit status : STATUS_NO_TRANSACTION $ $ [java] a simple transaction which is rolled back. $ [java] we set a transaction timeout to 1 second, begin the $ [java] transaction, and wait 5 seconds before commiting it: $ [java] - initial status : STATUS_NO_TRANSACTION $ [java] - after begin status : STATUS_ACTIVE $ [java] - wait for 5 seconds $ [java] - after rollback status : STATUS_NO_TRANSACTION $ $ [java] Trivial example is OK. $ $ ...
If you have the message Trivial example is OK., the
example is working. If it's not the case, double check your JOTM
settings. Most of the time, troubles come from incorrect settings
(clients try to access JOTM through RMI/JRMP whereas there is no RMI
registry but a CORBA name server,...).