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.
You 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:
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:
Click File-> Import-> EAR file
Click Next , then select the EAR file.
Click Finish .
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.
[For session beans only] Set the Transaction type attribute, which defines the transactional manner in which the container invokes a method. You can set this attribute to Container or Bean,
as follows:
To use container-managed transactions, set Container
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
This setting specifies the containment boundary at which all contained resource manager local transactions (RMLTs) must be completed. Possible values are Bean method or ActivitySession.
BeanMethod: This is the default value. If you select this option, RMLTs must be resolved within the same bean method in which they were started.
[For EJB components only] ActivitySession: RMLTs must be resolved within the scope of any ActivitySession in which they were started or, if no ActivitySession context is present, within the same bean method in which they were started.
Note: The ActivitySession option is not supported in the web container.
Resolver
This setting specifies the component responsible for initiating and ending RMLTs. Possible values are Application or ContainerAtBoundary.
Application: This is the default value. The application is responsible for starting RMLTs and for completing them within the local transaction containment (LTC) boundary. Any RMLTs that are not completed by the end of the LTC boundary are cleaned up by the container according to the value of the Unresolved action attribute.
ContainerAtBoundary: The container is responsible for starting RMLTs and for completing them within the LTC boundary. The container begins an RMLT
when a connection is first used within the LTC scope, and completes it automatically at the end of the LTC scope. If Boundary is set to ActivitySession, the RMLTs are enlisted as ActivitySession resources and directed to complete by the ActivitySession. If Boundary is set to BeanMethod, the RMLTs are committed at the end of the method by the container.
Unresolved action
The direction that the container requests RMLTs to take, if they are unresolved at the end of the LTC boundary scope and the Resolver is set to Application. Possible values are Rollback or
Commit .
Rollback: This is the default value. At end of the LTC boundary scope,
the container instructs all unresolved RMLTs to roll back.
Commit: At the end of the LTC boundary scope, the container instructs all unresolved RMLTs to commit. The container will instruct the RMLTs to commit only in the absence of an un-handled exception. If the application method executing under the local transaction context ends with an exception, any unresolved RMLTs are rolled back by the container. (This is the same behavior as for global transactions.)
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.] 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.
Execute using Web Services Atomic Transaction on incoming requests
[For web components only.] 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.
[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:
In the deployment descriptor notebook, select the Assembly tab. The Container Transactions box displays a table of the methods for enterprise beans.
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.
[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 support in 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.
[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.
Save your changes to the deployment descriptor.
Close the deployment descriptor editor.
When prompted, click Yes to indicate that you want to save changes to the deployment descriptor.
From the popup menu of the project, click
Deploy to generate EJB deployment code.
Optional: Test your completed module on a WebSphere Application Server 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; you cannot deploy remotely from the Application Server Toolkit (AST) or Rational Web Developer to a WebSphere Application Server 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 WebSphere Application Server 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.