To use the Servlet with Enterprise JavaBean example, see the following sections:
This Enterprise JavaBean (EJBean) example package contains the classes and other files necessary to set up and run an EJBean stateful session to a Tuxedo Server using Jolt. The package contents are as follows:
Teller(remote interface documentation and source)
TellerHome(home interface documentation and source)
TellerResult(application-specific utility documentation and source)
ProcessingErrorException(application-specific exception documentation and source)
TransactionErrorException(application-specific exception documentation and source)
This example demonstrates an Enterprise JavaBean (EJBean), and provides an example of a simple interface for accessing the Tuxedo Server. You can find the source code for this example in the
/samples/jolt/wls/ejb/bankapp directory included in the Oracle Tuxedo distribution.
Running this example before attempting to create your own EJBeans 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 as follows:
The client browser application performs these steps:
|Note:||In Transaction 1, a single call is made, and is automatically committed. In Transaction 2, a
To get the most out of this example, first read through the source code files to see what is happening. Start with
DeploymentDescriptor.txt to find the general structure of the EJBean and which classes are used for the different objects and interfaces, and then look at
Client.java to see how the application works.
The following sections provide details for using this example:
You need to add a Jolt connection pool that connects to the public Tuxedo Server at Oracle, as described in “Step 3. Configure the Servlet in WebLogic Server,” in Appendix B, Simple Servlet Example. When you’re finished, the
config.xml configuration file will contain the following sections:
Name="MyJolt Connection Pool"
After configuring your WebLogic Server development environment, you need to build the example. Oracle Jolt provides separate build scripts for Windows 2003 and UNIX, as follows:
The scripts build individual examples, such as this entry for Windows 2003:
To build under Microsoft’s JDK for Java, use:
$ build -ms
The scripts will build the example and place the files in the following default WebLogic Server directories on a Windows 2003 system:
When WebLogic Server is started in the default
\config\mydomain directory, the EJBean example is automatically deployed in the
\config\mydomaindirectory. 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 Deployments. You should see
ejb.jolt.bankappdeployed and should be able to monitor its activity.
$ java examples.jolt.ejb.bankapp.Client
$ java examples.jolt.ejb.bankapp.Client "t3://WebLogicURL:Port"
4. Beginning jolt.bankapp.Client...
6. Created teller Terry
8. Getting current balance of Account 10000 for Erin
9. Balance: 27924.02
11. Start Transaction 1 for Erin
13. Depositing 100.0 for Erin
14. Balance: 28024.02
16. End Transaction 1 for Erin
18. Start Transaction 2 for Erin
20. Depositing 200.0 for Erin
21. Balance: 28224.02
23. Withdrawing 28324.02 for Erin
24. Transaction error:
25. examples.jolt.ejb.bankapp.TransactionErrorException: Teller error: application
27. Account Overdraft
29. Rolling back transaction for Erin
31. End Transaction 2 for Erin
33. Getting final balance of Account 10000 for Erin
34. Balance: 28024.02
36. Removing teller Terry
|Note:||Note how the final balance shows that Transaction 2 was rolled back to the balance at the end of Transaction 1.|
You can read more about EJBs in the Programming WebLogic Enterprise JavaBeans guide. To learn more about using Oracle Jolt, refer to the Using Oracle Jolt guide.