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 (BasicExample 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, BasicExample. They just differ in their settings: one is for RMI/JRMP communication whereas the other is a pure RMI/IIOP client.
$ rmiregistry -J-classpath -Jjotm.jar:jotm_jrmp_stubs.jar \ -J-Djava.security.policy=../config/java.policy &Then in $JOTM_HOME/lib/, type
$ java -classpath jotm.jar:jotm_jrmp_stubs.jar:../config/ \ org.objectweb.jotm.Main -u UserTransaction &(on one line)
And in the basic/ directory, type
$ ant run.rmi.jrmp(by default JOTM is configured to run on RMI/JRMP so you don't have to modify $JOTM_HOME/config/carol.properties file to run example on it).
Then type
$ tnameserv -ORBInitialPort 19751 &Then in $JOTM_HOME/lib/, type
$ java -classpath jotm.jar:jotm_iiop_stubs.jar:../config/ \ org.objectweb.jotm.Main -u UserTransaction &(on one line)
And in the basic/ directory, type
$ ant run.rmi.iiop
Then type in $JOTM_HOME/lib/,
$ tnameserver -ORBInitialPort 19751 & $ rmiregistry -J-classpath -Jjotm.jar:jotm_jrmp_stubs.jar \ -J-Djava.security.policy=../config/java.policy &Then in $JOTM_HOME/lib/, type
$ java -classpath \ jotm.jar:jotm_jrmp_stubs.jar:jotm_iiop_stubs.jar:../config/ \ org.objectweb.jotm.Main -u UserTransaction &(on one line)
Finally you can acces JOTM on both RMI/JRMP or RMI/IIOP. in the basic/ directory, type
$ 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] Basic example is OK. $ $ ...
If you have the message Basic 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,...).