![]() |
![]() |
e-docs > Tuxedo > Using Jolt with WebLogic Server > Servlet with Enterprise JavaBean Example |
Using Jolt with WebLogic Server
|
Servlet with Enterprise JavaBean Example
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:
About the Servlet with JavaBean Example
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 BEA 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:
Preparing to Use the Servlet with JavaBean Example
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:
Set Up Your Environment
You need to add a Jolt connection pool that connects to the public Tuxedo Server at BEA, 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:
<StartupClass
ClassName="bea.jolt.pool.servlet.weblogic.PoolManagerStartUp"
FailureIsFatal="false"
Name="MyStartup Class"
Targets="myserver"
/>
<JoltConnectionPool
ApplicationPassword="tuxedo"
MaximumPoolSize="5"
MinimumPoolSize="3"
Name="MyJolt Connection Pool"
PrimaryAddresses="//TUXSERVER:6309"
RecvTimeout="300"
SecurityContextEnabled="true"
Targets="myserver"
UserName="joltuser"
UserPassword="jolttest"
UserRole="clt"
/>|
<ShutdownClass
ClassName="bea.jolt.pool.servlet.weblogic.PoolManager
ShutDown."
/>
Build the Example
After configuring your WebLogic Server development environment, you need to build the example. BEA Jolt provides separate build scripts for Windows 2000 and UNIX, as follows:
The scripts build individual examples, such as this entry for Windows 2000:
$ build
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 2000 system:
Run the Servlet with JavaBean Example
When WebLogic Server is started in the default \config\mydomain directory, the EJBean example is automatically deployed in the \applications directory.
$ java examples.jolt.ejb.bankapp.Client
If you are not running the WebLogic Server with its default settings, you will have to use the following command line:
$ java examples.jolt.ejb.bankapp.Client "t3://WebLogicURL:Port"
where the following parameters are defined as follows:
4. Beginning jolt.bankapp.Client...
5.
6. Created teller Terry
7.
8. Getting current balance of Account 10000 for Erin
9. Balance: 27924.02
10.
11. Start Transaction 1 for Erin
12.
13. Depositing 100.0 for Erin
14. Balance: 28024.02
15.
16. End Transaction 1 for Erin
17.
18. Start Transaction 2 for Erin
19.
20. Depositing 200.0 for Erin
21. Balance: 28224.02
22.
23. Withdrawing 28324.02 for Erin
24. Transaction error:
25. examples.jolt.ejb.bankapp.TransactionErrorException: Teller error: application
26. exception:
27. Account Overdraft
28.
29. Rolling back transaction for Erin
30.
31. End Transaction 2 for Erin
32.
33. Getting final balance of Account 10000 for Erin
34. Balance: 28024.02
35.
36. Removing teller Terry
37.
End jolt.bankapp.Client...
You can read more about EJBs in the Programming WebLogic Enterprise JavaBeans guide. To learn more about using BEA Jolt, refer to the Using BEA Jolt guide.
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |