WebLogic Server 11g

Date: 09/01/09
Bill Dettelback, Hiromu Kato, Paul Parkinson

How-To: Achieve Zero Data Loss with WebLogic Clusters

  • Create a new WebLogic Domain from an existing domain template
  • Configure XA Data Sources in a WebLogic cluster
  • Set up WebLogic Diagnostics Framework to log transaction context in the cluster
  • Run the Zero Data Loss Demonstration application

Software Requirements

  • WebLogic Server 11g (10.3.1), available from OTN
  • Either Zero Data Loss Demonstration Domain Template, available here
  • ...or, Zero Data Loss Demonstration Application, available here
  • Oracle XE Database (if required), available here


  • %FMW_HOME% - The directory where you installed WebLogic Server 11g.
  • %APP_HOME% - The directory where you extracted the Zero Data Loss Demonstration application ZIP file.


The following software must be installed prior to running this How To:

  • WebLogic Server 11g (10.3.1)
  • Oracle Database 10g or higher (XE is fine)


Solution Description

A four-node WebLogic cluster is shown below with a fifth node (AdminServer) hosting a Servlet.  The Servlet receives trade orders from a browser and submits them to the cluster to be processed.  A stateless EJB on one of the clustered nodes is selected via round-robin load balancing which handles the writing of both a trade order record and a trade message record across two Data Sources.  The two records are part of a single XA transaction, however to keep things simpler we will use a single instance of Oracle XE.

Creating the Domain From the Template

1. Start Configuration Wizard (Start->Programs->Oracle WebLogic->WebLogic Server 11gR1->Tools->Configuration Wizard).

2. Choose "Create a new WebLogic domain".  Click "Next".

3. Choose "Base this domain on an existing template".  Click Browse.  Locate the file zeroloss_domain_10.3.1.0.jar.  Click "OK".  Click "Next".

4. Either keep the default values for domain name and location, or select new values (by default Configuration Wizard will put the domain under your  user_projects directory).  Click "Next".

5. Either keep the default administrator credentials (weblogic/abcd1234) or choose new credentials.  Click "Next".

6. Keep the default server start mode and JDK selections.  Click "Next".

7. The JDBC Data Sources have been pre-configured for Oracle XE running on localhost:1521 with user 'weblogic' and password 'abcd1234'.  Adjust accordingly to match your current database installation.  Note there are three data sources configured- two for the Trade orders and another to handle WLDF event records.  Click Next and Configuration Wizard will attempt to verify the connections.  Click Next once the connections have been verified.

8. The domain template also contains a set of database scripts, which will configure the appropriate tables and sequences needed by WLDF and the application.  Click the "Run Scripts" button and verify there are no errors in the Results pane- you should see  CFGFWK-20839:  Database Load Successful!.  Click "Next".

9. We will not modify any Optional Configurations.  Click "Next".

10. Scan through the Configuration Summary to ensure everything is correct, and then click "Create".

11. Click "Done" to exit the Configuration Wizard.

Skip the next section to "Running the Application" to walk through the application.

Creating the Domain Manually

1. Start Configuration Wizard (Start->Programs->Oracle WebLogic->WebLogic Server 11gR1->Tools->Configuration Wizard).

2. Choose "Create a new WebLogic domain".  Click "Next".

3. Choose "Generate a domain configured automatically to support the following products:".  Make sure "Basic WebLogic Server Domain" is checked.  Click "Next".

4. Change the name of the domain to 'zeroloss_domain'.  You may keep the default location or choose another directory.  Click Next;

5. Set up Administrator username as 'weblogic'.  Choose 'abcd1234' as password or any other password you desire that meets the criteria.  Click Next.

6. Keep the default server start mode and JDK selections.  Click "Next".

7. We will not modify any Optional Configurations.  Click "Next".

8. Scan through the Configuration Summary to ensure everything is correct, then click "Create".

9. Click "Done" to exit the Configuration Wizard.

Log into the WebLogic Console


      Creating the Cluster

      node1 7004
      node2 7005
      node3 7006

      Configuring the Data Sources and Database Tables

      OracleDS2 jdbc/OracleDS2
      WLDF-DS jdbc/WLDF-DS

      1. cre_seq.sql
      2. sleep_wait.sql
      3. trade_message.sql
      4. trade_order.sql
      5. wldf.sql

      Configuring WebLogic Diagnostics Framework

      Building and Deploying the Application


      ant build


      Running the Application

      1. Start Node Manager using Start->Programs->Oracle WebLogic->WebLogic Server 11gR1->Tools->Node Manager or on the command line at %FMW_HOME%\wlserver_10.3\server\bin\startNodeManager.cmd.

      2. If the Admin server is not already running, start the admin server by executing the following command: %FMW_HOME%\user_projects\domains\zeroloss_domain\startWebLogic.cmd

      3. Login to the WebLogic Administration Console: http://localhost:7001/console using the credentials specified during domain creation

      4. Click on  the "Servers" node under "Environment" in the Domain Structure tree.

      5. Select the "Control" tab on Summary of Servers page.  Check each node in the cluster and click "Start".

      After a few minutes, and all nodes have started, refreshing the browser should provide the following in the table of servers:

      6. Go to the Trade Capture page at http://localhost:7001/ZeroLossProjectWeb/trade.jsp.

      Click the "Submit" button to create a trade order.  You should see in the "message output" line some debug output showing what was written to the database.  Of particular note is the portion on the second line with the node name.  If you click the "Submit" button several times, you should see the node names cycling through each name- indicating that our round robin strategy is working for the cluster.  The exact order is selected by WebLogic internally, and may not follow the sequential node numbers directly.  Make a note of the sequence you are observing.  For this example, we have observed "node0", "node1", "node3", "node2" being used.

      7. In another browser window/tab, go to the page at http://localhost:7001/ZeroLossProjectWeb/LastTradesServlet?numResults=20

      This page shows the last 20 trades with the last trade as the first item.  Note that the table shows which cluster node began the transaction and which cluster node committed the transaction.  For each of the runs done in step 4 you will (hopefully) have the same node name in both columns.

      8. Now let's simulate a node failure.  Go back to the Trade Capture page and look at the last transaction completed.  Note which node was used- in the screenshot below "node2" was used; this means that according to round robin, "node0" will be the next node selected.

      9. Go back to the WebLogic Server console and bring up the list of Servers.  Make sure the "Control" tab is selected.  Check the box next to the node which will be chosen for the next transaction.   Don't stop the node yet- we want it to be available to receive the transaction.  We are simply getting this page ready for a subsequent step.

      10. Go back to the Trade Capture page and this time change the Sleep parameter to 20 seconds.  This will cause the EJB to pause mid-transaction so that we can kill its node and cause the retry.  Hit "Submit" and notice that the page does not return immediately.

      11. Switch back to the WebLogic Server console page and click on the "Shutdown" button- choose "Force Shutdown Now".

      12.  Switch back to the Trade Capture- you should notice that the node which handled the trade is the next node after the one you shut down in the round-robin schedule.  For the example below, "node1" was chosen since "node0" failed.

      This indicates that while "node0" went away mid-transaction, the cluster was able to retry the transaction on another node, preventing data loss.

      13. Go to the Control Panel page, click the "Show the last trades" link to refresh the table, and the most recent trade should be highlighted as shown below.  This indicates that the node which received the transaction did not match the node which ultimately committed the transaction.

      Understanding the use of WebLogic Diagnostics Framework



      • Load-balancing happens automatically in the cluster as requests are sent by the Servlet.
      • Retried transactions are picked up by the next available node according to the load balancing algorithm.

      For More Information

      WebLogic Server page

      Introduction to the WebLogic Diagnostics Framework (WLDF), by Rebecca Sly
      Monitoring Performance Using the WebLogic Diagnostics Framework, by Mike Cico