uCosminexus Application Server, EJB Container Functionality Guide

[Contents][Glossary][Index][Back][Next]

3.5.1 Procedure for using a transaction in the EJB client

To use a transaction in the EJB client application:

  1. Add the following JAR files to the class path specified during the startup of the EJB client application:
    • In Windows
      Cosminexus-installation-directory\TPB\lib\tpotsinproc.jar
      Cosminexus-installation-directory\CC\lib\ejbserver.jar#
    • In UNIX
      /opt/Cosminexus/TPB/lib/tpotsinproc.jar
      /opt/Cosminexus/CC/lib/ejbserver.jar#
    #
    Add ejbserver.jar after HiEJBClientStatic.jar.
  2. Add the system properties required during the startup of the EJB client application.
    For details on how to add system properties, see 3.20 Points to be considered when starting a transaction in the EJB client applications in the uCosminexus Application Server Common Container Functionality Guide.
  3. Immediately after the startup of the process of the EJB client application, execute the initialization processing of the service from the user codes implemented in the EJB client application.
    To execute the initialization processing of the service, invoke the EJBClientInitializer class (com.hitachi.software.ejb.ejbclient.EJBClientInitializer).
    Note that if you generate javax.naming.InitialContext, and invoke the getUserTransaction method of the UserTransactionFactory class before invoking the initialize method of the EJBClientInitializer class, the initialization processing will be executed at that point of time. Therefore, you need not execute the initialization processing in the EJBClientInitializer class.
    For details on the syntax and functionality of the EJBClientInitializer class, see 4.2 EJBClientInitializer class in the uCosminexus Application Server API Reference Guide.
  4. Obtain the UserTransaction object.
    The UserTransaction object is obtained with either of the following two methods:
    • Using the UserTransactionFactory class
      Obtain the UserTransaction object using the getUserTransaction method of the com.hitachi.software.ejb.ejbclient.UserTransactionFactory class. For details on the syntax and functionality of the UserTransactionFactory class, see 4.5 UserTransactionFactory class in the uCosminexus Application Server API Reference Guide.
    • Using lookup
      Obtain the UserTransaction object using the look up from the naming service. For details on how to obtain the UserTransaction object using lookup, see 3.4.8 Process overview and points to be considered when using UserTransaction interface in the uCosminexus Application Server Common Container Functionality Guide.
    Hitachi recommends that in the EJB client you obtain UserTransaction using the UserTransactionFactory class. However, if you are not able to change the source codes of the EJB client application because of the migration from an application server of another company, use lookup.
  5. From the thread that invokes the Enterprise Bean, invoke the begin method of the UserTransaction interface and start the transaction.
  6. Invoke the Enterprise Bean running on the server.
  7. From the thread that invokes the Enterprise Bean, invoke the commit method or the rollback method of the UserTransaction interface and conclude the transaction.