}
}
Files
Prepare
Run
Troubleshooting
Related Topics
About the Example
This example shows how to use JTA to perform distributed transactions
using the two phase commit protocol across two XA resources: a JMS queue and
a Pointbase database instance.
This example does the following:
- The Client prompts
the user for test messages. The Client then sends the messages to the JMS queue, initializes the database table, and
calls ReceiveInTxBean EJB.
- ReceiveInTxBean EJB
in turn begins a distributed transaction, receives messages from the JMS
queue, updates the database, and then commits the distributed transaction.
- The Client then
verifies that the data is updated in the database and cleans up the database
table.
Files Used in the Example
Directory Location:
MW_HOME/wlserver_10.3/samples/server/examples/jta/jmsjdbc/
(where MW_HOME is the directory containing your WebLogic Server installation)
File
Click source
files to view code.
|
Description
|
application.xml
| The Java EE standard enterprise application deployment descriptor.
|
build.xml
| Ant build file that contains targets for building and running the example.
|
Client.java
| Class used to illustrate how to use JTA to perform distributed transactions
and two phase commit across two XA resources: JMS queue and
Pointbase database.
|
ReceiveInTxBean.java
| ReceiveInTxBean is a stateless session bean using bean-managed
transaction. This EJBean illustrates distributed transactions
and two phase commit across two XA resources: JMS queue and
a Pointbase database. It begins a distributed transaction, receives
messages from the JMS queue, updates the database, and then commits
the distributed transaction.
|
weblogic-application.xml
| The WebLogic Server-specific enterprise application deployment descriptor.
|
Prepare the Example
Prerequisites
Before working with this example:
- Install
WebLogic Server, including the
examples.
- Start
the Examples server.
- Set
up your environment.
Configure WebLogic Server
- Bring up the Administration Console in your browser.
- Click to expand the Services > Messaging > JMS Modules in the left pane.
- Verify that the exampleQueue connection factory is deployed on the examplesServer as follows:
- Select the examples-jms node. The configuration information displays in one tab in the right pane.
- Select the Targets tab in the right pane and make sure that examplesServer is selected.
- Click the tree in the left pane to expand the Services -> JDBC nodes.
- Verify that the examples-demoXA JDBC Data Source is deployed on the examplesServer as follows:
- Select examples-demoXA by clicking on its entry in the right pane.
- Select the Targets tab in the right pane and make sure that examplesServer is selected.
- Select the Monitoring tab and make sure that the examples-demoXA is running on the examplesServer.
Build and Deploy the Example
- Set up your development shell as described in
Setting up your environment.
- Change to the following directory: %SAMPLES_HOME%\server\examples\src\examples\jta\jmsjdbc, which contains
an ant build script to build the example.
- Execute the following command:
ant build
This command compiles and stages the example.
- Execute the following command:
ant deploy
This command deploys the example on the wl_server domain
of your WebLogic Server installation.
-
This script builds the example and places the files in the
correct locations:
- Client files: in %SAMPLES_HOME%\server\examples\build\clientclasses
- EJB: in %SAMPLES_HOME%\server\examples\build\jtaJmsJdbcEar\jtaJmsJdbcEjb
Running the build script builds the EJB in split development directory format
where compiled and generated classes are placed in SAMPLES_HOME\server\examples\build\jtaJmsJdbcEar
and non-compiled files remain within the source directory of the example.
For more information on split development directory, see Developing WebLogic Server Applications.
Run the Example
- Complete the steps in the "Prepare
the Example" section.
- Execute the following command from the shell where you set your environment:
ant run
This command runs the example.
- When prompted, enter messages into
the client shell. After the last message,
enter "quit".
- In the client shell, you should see something like the following:
Enter message ("quit" to quit): hello
JMS Message Sent: hello
Enter message ("quit" to quit): bea
JMS Message Sent: bea
Enter message ("quit" to quit): quit
JMS Message Sent: quit
Data found in database:
hello
bea
- In the server shell, you should see something like the following:
TRANSACTION BEGUN
Message Received: hello
Message Received: bea
Message Received: quit
TRANSACTION COMMITTED
Troubleshooting
- After entering the messages and executing "quit", ifthe example throws "java.lang.NoClassDefFoundError: examples/jta/jmsjdbc/ReceiveInTxHome" exception.
Be sure to set your CLASSPATH using the following command (for Windows):
set CLASSPATH=%SAMPLES_HOME%\server\examples\build\clientclasses;%SAMPLES_HOME%\server\examples\build\jtaJmsJdbcEar\jtaJmsJdbcEjb;%CLASSPATH%
- General
Troubleshooting Tips for Examples
Related Topics
(Internet connection required.)