All Examples  All Jolt Examples  This Package

Package examples.jolt.ejb.bankapp

Enterprise JavaBean stateful session to TUXEDO Server using Jolt
example package and classes

about this example

This example is a package that demonstrates an Enterprise JavaBean. Please run this example before attempting to create your own Enterprise JavaBeans, as it will show you the different steps involved. The example is a stateful session EJBean called TellerBean that contacts a TUXEDO Server using Jolt for WebLogic and conducts transactions.

The example demonstrates:

The Client application performs these steps:
  1. Contacts the Teller home ("TellerHome") through JNDI to find the EJBean
  2. Creates a Teller ("Terry")
  3. The application then:
    1. Gets the current balance for account 10000
    2. Transaction 1: Deposits 100 into the account, and displays the balance
    3. Transaction 2: Deposits 200 (more than the transaction limit of 300)
    4. Attempts to withdraw 100 more than the balance of the account
    5. Catches an ApplicationException, retreives the status messages embedded in the exception and rolls back Transaction 2
    6. Gets the final balance for the account
  4. Removes the Teller
You can see in the Transaction 2 how the balance is successfully rolled back to what it was at the end of Transaction 1.

Note that in Transaction 1, a single call is made, and is automatically committed. In Transaction 2, a begin() and commit() bracket two seperate requests (a deposit and a withdrawl).

The bean provides an example of a simple interface for accessing the TUXEDO Server.

how to use this example

To get the most out of this example, first read through the source code files to see what is happening. Start with the XML deployment files to find the general structure of the EJBean, which classes are used for the different objects and interfaces, then look at to see how the application works.

In general, you will need to adjust certain properties to match your setup. you will need to edit the entry for the property that begins with "weblogic.ejb.deploy" in the file to deploy the EJBean. The property is commented out in the default properties file; make sure that you uncomment out all the lines of the property.

These three sections cover what to do:

  1. Build the example
  2. Set your environment
  3. Run the example

Build the example

Copy the files in this directory to your WebLogic document root. The default document root is the myserver/public_html directory in WebLogic home.

Set up your development environment as described in Setting your development environment.

We provide separate build scripts (in the directory above this one: /examples/jolt/ejb) for Windows NT and UNIX:

The "build" scripts build individual examples, such as this entry for Windows:

$ build
These scripts will build the example and place the files in the correct locations:

Set your environment

Deploy the EJBean by adding the path to the .jar file to the "weblogic.ejb.deploy" property.

We provide a commented-out version in the property that begins with "weblogic.ejb.deploy" that you can use. you will need to adjust the property depending on which EJBeans you are building and are deploying, or if the location of the files differs from the installed location.

Note: If you are running under the Microsoft SDK for Java add the path to the .jar to the CLASSPATH for your WebLogic Server.

Add a Jolt connection pool that connects to your TUXEDO server. See Implementing Jolt for WebLogic for information on how to set up your server.

Here is a sample file:

# Demo Jolt pool



Run the example

  1. Start a TUXEDO server on the machine and port you have designated in the file.
  2. Start the WebLogic Server. You can check that the EJBean has been deployed correctly either by checking the server command line window, or by opening the Console and examining "EJB" under the "Distributed objects"; you should see bankapp.TellerHome deployed, and can monitor its activity.
  3. Run the client in a separate command line window. Set up your client as described in Setting your development environment, and then run the client by entering:
    $ java examples.jolt.ejb.bankapp.Client

    If you are not running the WebLogic Server with its default settings, you will have to run the client using:

    $ java examples.jolt.ejb.bankapp.Client "t3://WebLogicURL:Port"


    Domain address of the WebLogic Server
    Port that is listening for connections (weblogic.system.ListenPort)

    Parameters are optional, but if any are supplied, they are interpreted in this order:

    url - URL such as "t3://localhost:7001" of Server
    user - User name, default null
    password - User password, default null

  4. If you are running the Client example, you should get output similar to this from the client application:
    Beginning jolt.bankapp.Client...
    Created teller Terry
    Getting current balance of Account 10000 for Erin
    Balance: 27924.02
    Start Transaction 1 for Erin
      Depositing 100.0 for Erin
      Balance: 28024.02
    End Transaction 1 for Erin
    Start Transaction 2 for Erin
      Depositing 200.0 for Erin
      Balance: 28224.02
      Withdrawing 28324.02 for Erin
      Transaction error:
      examples.jolt.ejb.bankapp.TransactionErrorException: Teller error: application
    Account Overdraft
      Rolling back transaction for Erin
    End Transaction 2 for Erin
    Getting final balance of Account 10000 for Erin
    Balance: 28024.02
    Removing teller Terry
    End jolt.bankapp.Client...
    Note how the final balance shows that Transaction 2 was rolled back to the balance at the end of Transaction 1.

there's more

Read more about EJB in BEA WebLogic Server Enterprise JavaBeans.

Read more about Jolt in the Jolt for WebLogic Server User's Guide.

Copyright © 1998-2000 BEA Systems, Inc. All rights reserved.

Last updated 03/20/2000