private JOTMTransactionManager(
      XaDataSourceManager xaDataSourceManager, TransactionStateFactory stateFactory) {
    this.xaDataSourceManager = xaDataSourceManager;
    this.stateFactory = stateFactory;

    Registry registry = null;
    try {
      registry = LocateRegistry.getRegistry(1099);
    } catch (RemoteException re) {
      // Nothing yet, we can still create it.
    }
    if (registry == null) {
      try {
        registry = LocateRegistry.createRegistry(1099);
      } catch (RemoteException re) {
        // Something is fishy here, plus it is impossible to continue.
        // So we die.
        throw new Error(re);
      }
    }
    try {
      jotm = new Jotm(true, false);
      current = jotm.getTransactionManager();
    } catch (NamingException ne) {
      throw new Error("Error during JOTM creation", ne);
    }
  }
 /** Stops the JOTM instance. */
 @Override
 public void stop() {
   jotm.stop();
 }