Configure transactional deployment attributes

Use this task to configure the transactional deployment descriptor attributes associated with an EJB or Web module, to enable a J2EE application to use transactions.

 

Overview

One can configure the deployment attributes of an application by using an assembly tool such as the Application Server Toolkit (AST) or Rational Web Developer.

This topic describes the use of the Application Server Toolkit (AST) to configure the deployment attributes of an application. This task description assumes that you have an EAR file for an application component, that can be deployed in WebSphere Application Server. For more details about assembling applications, see Assembling applications.

To set transactional attributes in the deployment descriptor for an application component (enterprise bean or servlet), complete the following steps:

 

Procedure

  1. Start the assembly tool.

  2. Create or edit the application EAR file. For example, to change attributes of an existing application, use the import wizard to import the EAR file into the assembly tool. To start the import wizard:

    1. Click File-> Import-> EAR file

    2. Click Next, then select the EAR file.

    3. Click Finish.

  3. In the J2EE Hierarchy view, right-click the component instance, then click Open With > Deployment Descriptor Editor. For example:

    • For a session bean, expand EJB Modules-> ejb_module_instance-> Deployment Descriptor-> Session Beans then select the bean instance.

    • For a servlet, expand Web Modules-> web_application-> Deployment Descriptor-> web component then select the servlet instance.

    A property dialog notebook for the component's deployment descriptor is displayed in the property pane.

  4. [For session beans only] Set the Transaction type attribute, which defines the transactional manner in which the container invokes a method. We can set this attribute to Container or Bean, as follows:

    • To use container-managed transactions, set Container

    • To use bean-managed transactions, set Bean

  5. In the deployment descriptor notebook, select the Bean tab. Under WebSphere Extensions, optionally configure Local Transaction. To enable management of local transaction containments, configure the following component extensions attributes. These attributes configure, for the component, the behavior of the container's local transaction containment (LTC) environment that the container establishes whenever a global transaction is not present.

    Boundary

    Duration of a local transaction context. We can set this attribute to Bean method or ActivitySession.

    Note: The ActivitySession option is not supported in the web container.

    Resolver

    Specifies how the resource manager local transaction is to be resolved by the application through user code or by the container. We can set this attribute to either Application or ContainerAtBoundary.

    Unresolved action

    Specifies the action that the container must take when the local transaction context scope ends, if resources are uncommitted by an application in a local transaction and the Resolution control is set to Application. We can set this attribute to either Commit or Rollback.

    For a value of Commit, the container will take the commit action only in the absence of an un-handled exception. If the application method executing under the local transaction context ends with an exception, then the local transaction context is rolled back by the container. (This is the same behavior as for global transactions.)

  6. Continuing in WebSphere Extensions, configure Global Transaction. These attributes configure, for the component, behavior in the presence of a global transaction.

    Component Transaction Timeout

    [For enterprise beans using container managed transactions only.] Specifies the transaction timeout, in seconds, for any new global transaction started by the container on behalf of the enterprise bean. Any value specified overrides, for transactions started on behalf of the component, the default transaction timeout configured on the application server.

    Use Web Services Atomic Transaction

    [For enterprise beans only.] Specifies whether the application component, if it makes any Web service requests, expects any transaction context to be propagated with the Web service requests in accordance with the WebSphere WS-AtomicTransaction support described in Web Services – Atomic Transaction for WebSphere Application Server. Unless specified using this attribute, Web service requests do not carry transaction context.

    Send Web Services Atomic Transaction on requests

    [For web components only.] Specifies whether the application component, if it makes any Web service requests, expects any transaction context to be propagated with the Web service requests in accordance with the WebSphere WS-AtomicTransaction support described in Web Services – Atomic Transaction for WebSphere Application Server. Unless specified using this attribute, Web service requests do not carry transaction context.

    Execute using Web Services Atomic Transaction on incoming requests

    [For web components only.] Specifies whether web application components are prepared to run under a received WS-AtomicTransaction context. Unless specified using this attribute, the web application component's container suspends any received transaction context in a similar manner to the EJB container's behavior for an enterprise bean deployed with a Container transaction type of NotSupported. Setting this attribute enables a web application component to run under a received WS-AtomicTransaction context in a similar fashion to an enterprise bean deployed with a Container transaction type of Supports.

  7. [For EJB components only] For container-managed transactions, configure how the container must manage the transaction boundaries when delegating a method invocation to an enterprise bean's business method:

    1. In the deployment descriptor notebook, select the Assembly tab. The Container Transactions box displays a table of the methods for enterprise beans.

    2. For each method of the enterprise bean set the Container transaction type to an appropriate value. The default value for the Container transaction type is Required, meaning that the method invocation occurs in the context of a transaction. This transaction is either the (local or remote) client component's transaction or, if the client component does not execute under a transaction, a new transaction started by the component's container.

    If the application uses ActivitySessions, how the container manages transaction boundaries when delegating a method invocation depends on both the Container transaction type set in this task, and the ActivitySession kind attribute as described in Configuring ActivitySession deployment attributes for an enterprise JavaBean. For more detail about the relationship between these two properties, see Combining transaction and ActivitySession container policies.

  8. [For Web service applications that use a SOAP/JMS binding and participates in WS-AtomicTransactions] Ensure that the Container transaction type of the message-driven bean named JMS router MDB is set, as described in the previous step, to a value of NotSupported. Web service applications that use a SOAP/JMS binding include in the assembled EAR a router message-driven bean named JMS router MDB. If a Web service uses a SOAP/JMS binding and participates in WS-AtomicTransactions, as described in Web Services – Atomic Transaction for WebSphere Application Server, then the Container transaction type of the JMS router MDB must be set, as described in the previous step, to a value of NotSupported. Note that there is no equivalent action neccessary for Web service applications that use a SOAP/HTTP binding and participate in WS-AtomicTransactions.

  9. [For client application components only] Enable, if required, support for transaction demarcation by the client. In the deployment descriptor notebook, select the option Allow JTA demarcation. This directs the client container to bind the JTA UserTransaction interface into JNDI at java:comp/UserTransaction for the client component. There are constraints on the capabilities of the transaction support in the client container described in Client support for transactions.

  10. Save your changes to the deployment descriptor.

    1. Close the deployment descriptor editor.

    2. When prompted, click Yes to indicate that you want to save changes to the deployment descriptor.

  11. Verify the archive files.

  12. From the popup menu of the project, click Deploy to generate EJB deployment code.

  13. Optional: Test your completed module on a WAS installation. Right-click a module, click Run on Server, and follow the instructions in the displayed wizard. Note that Run on Server works on the Windows, Linux/Intel, and AIX operating systems only; one cannot deploy remotely from the Application Server Toolkit (AST) or Rational Web Developer to a WAS installation on a UNIX operating system such as Solaris. Important

    Note: Use Run On Server for unit testing only. The Application Server Toolkit (AST) or Rational Web Developer controls the WAS installation and, when an application is published remotely, the assembly tool overwrites the server configuration file for that server. Do not use on production servers.

 

What to do next

After assembling your application, use a systems management tool to deploy the EAR file onto the application server that is to run the application; for example, using the administrative console as described in Deploying and managing applications.


 

Related Tasks


Configuring transaction properties for an application server
Assembling applications

 

See Also


Combining transaction and ActivitySession container policies
Using local transactions

 

Related Information


Enterprise JavaBeans specification
WebSphere Application Server Development Best Practices for Performance and Scalability