developing enterprise javabeans - ibmenterprise javabeans or ejbs commonly contain the business...

45
IBM WebSphere Studio Application Developer Workshop - LAB EXERCISE Developing Enterprise JavaBeans What This Exercise is About Enterprise Javabeans are main components in enterprise applications today. Enterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications to create robust J2EE applications. WebSphere Studio Application Developer provides a number of tools for generating Enterprise Javabeans as well as adding EJBs to J2EE applications. There are tools for creating EJBs, associations, custom finders, and EJB Access Beans. All of these can be validated against the EJB v1.1 specification with a built-in validation option. WebSphere Studio Application Developer also provides a built-in EJB test client for unit testing EJBs in an application. There are specific deployment descriptor editors provided by WebSphere Studio Application Developer to prepare EJBs to be a part of a J2EE application. This exercise will feature EJB creation, validation, and updating of the necessary deployment descriptors in preparation of adding the EJBs to a complete J2EE application. The WebSphere v4.0 Testing environment will also be featured as EJBs are tested using the EJB Unit Test Client. User Requirement User must have DB2 (version 7.2) and WebSphere Studio Application Developer installed, and understand basic EJB concepts. The YourBank source code files, which will be used in building the EJBs, must be located at c:\yourbank\lab1. What You Should Be Able to Do After completing this lab you will understand the steps required to create and test Session and Container Managed Persistence Enterprise Javabeans using IBM WebSphere Studio Application Developer. You will understand how to validated EJBs against the EJB v1.1 specification. After your EJBs are created and validated, you should also be able to create a WebSphere v4.0 Test Environment server configuration and instance from scratch and from a template in order to test your EJBs. Finally, you should be able to test your EJBs using the EJB Unit Test Client. Introduction Entity and Session EJBs are used in applications to implement business logic. Entity EJBs are primarily used for accessing or representing persistent data within an application. Session EJBs access entity EJBs and use the data stored in the entity EJBs. In this lab you will create the © Copyright IBM Corporation 2001. All rights reserved. 2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 1 of 45

Upload: others

Post on 11-Jul-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

IBM WebSphere Studio Application Developer Workshop - LAB EXERCISE

Developing Enterprise JavaBeans

What This Exercise is About

Enterprise Javabeans are main components in enterprise applications today. EnterpriseJavabeans or EJBs commonly contain the business logic of an application and are combinedwith Servlets, JSPs, and client applications to create robust J2EE applications. WebSphereStudio Application Developer provides a number of tools for generating Enterprise Javabeans aswell as adding EJBs to J2EE applications. There are tools for creating EJBs, associations,custom finders, and EJB Access Beans. All of these can be validated against the EJB v1.1specification with a built-in validation option. WebSphere Studio Application Developer alsoprovides a built-in EJB test client for unit testing EJBs in an application. There are specificdeployment descriptor editors provided by WebSphere Studio Application Developer to prepareEJBs to be a part of a J2EE application. This exercise will feature EJB creation, validation, andupdating of the necessary deployment descriptors in preparation of adding the EJBs to acomplete J2EE application. The WebSphere v4.0 Testing environment will also be featured asEJBs are tested using the EJB Unit Test Client.

User Requirement

User must have DB2 (version 7.2) and WebSphere Studio Application Developer installed, andunderstand basic EJB concepts. The YourBank source code files, which will be used in buildingthe EJBs, must be located at c:\yourbank\lab1.

What You Should Be Able to Do

After completing this lab you will understand the steps required to create and test Session andContainer Managed Persistence Enterprise Javabeans using IBM WebSphere Studio ApplicationDeveloper. You will understand how to validated EJBs against the EJB v1.1 specification. Afteryour EJBs are created and validated, you should also be able to create a WebSphere v4.0 TestEnvironment server configuration and instance from scratch and from a template in order to testyour EJBs. Finally, you should be able to test your EJBs using the EJB Unit Test Client.

Introduction

Entity and Session EJBs are used in applications to implement business logic. Entity EJBs areprimarily used for accessing or representing persistent data within an application. Session EJBsaccess entity EJBs and use the data stored in the entity EJBs. In this lab you will create the

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 1 of 45

Page 2: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

Account and Transfer EJBs from scratch for the YourBank application. The Account EJB willrepresent a savings or checking account with a balance, for a particular customer. The Transfersession EJB will use the Account entity EJB to transfer money between different Account EJBs,given the two accounts in the transaction and amount to transfer.

** NOTE ** Solution instructions are at the end of Part Five

Exercise Instructions

Part One: Setup

__1. Start IBM WebSphere Studio Application Developer from the start menu (Start -->Programs --> IBM WebSphere Studio Application Developer --> IBM WebSphere StudioApplication Developer).

__2. Switch to the J2EE perspective by selecting Perspective --> Open --> Other --> J2EE.Verify that the J2EE view appears in the navigator frame. The J2EE perspective isdifferent from other perspectives because it organizes projects based on the type ofmodule (EJB or Web).

__3. Create a new EJB project.

__ From the main menu select: File --> New --> Project, then select EJB and then EJBProject from the SmartGuide. You could also click the Create an EJB Project toolbar

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 2 of 45

Page 3: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

button (the nineth button from the left in the toolbar)..

__ Name the EJB Project: YourBankEJBModule.

__ Make sure the Use default location is checked.

__ Use YourBankEAR for the EAR Project name and click Finish.

The project YourBankEAR, will be used to package all parts of the YourBank application.

__ Verify that an EAR project called Application YourBankEAR is created. ExpandEnterprise Applications. The corresponding module, YourBankEJBModule, shouldappear in the J2EE view under EJB Modules.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 3 of 45

Page 4: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

Switch to the Navigator view by selecting the tab at the bottom of the J2EE view andverify that two new projects, YourBankEJBModule and YourBankEAR, are created.This view can also be used when working with J2EE applications, however it does notorganize the modules by Type.

Part Two: Creating the Account CMP entity bean

__1. In the J2EE Perspective, from the main menu select File --> New --> Enterprise bean.

You can also click the Create an Enterprise Bean toolbar button (the eighth button fromthe left in the toolbar). This will launch the Create EJB wizard.

__ Name the bean Account.

__ Select YourBankEJBModule as the EJB project.

__ Select Entity bean with container-managed persistence (CMP) fields as the Bean type.

__ Verify the Default package root field value is ejbModule.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 4 of 45

Page 5: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ In the Bean class field, enter com.ibm.yourbank.ejb. (In front of AccountBean) Notice that the Home and Remote interface package fields are automatically filled in.

__2. The next step is to add the persistence fields managed by the container. In the Addpersistence fields to the bean section, click Add....

__ Enter accountNumber for the Field name.

__ Select long for the Field type.

__ Enter 0 in the Initial value field.

__ Ensure that Key field is checked.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 5 of 45

Page 6: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Click Add.

__3. You have created one persistence field and now need to create three more.

__ Enter type for the Field name, select int from the Field type drop down box and enter1 into the Initial value field. Leave the rest of the check boxes unselected. Click Add.

__ Enter balance for the Field name. Select float from the Field type drop down box.Enter 0 in the Initial value field. Ensure that the Access with getter and setter methodsand Promote getter and setter methods to remote interface check boxes areselected. With these boxes checked, the value for balance can be referenced and setfrom methods within the bean. The Promote check box makes these methods to get andset the balance available to the client in the Remote interface.

__ Click Add.

__ Enter accountOwner for the Field name. Select java.lang.String from the Field typedrop down box. Enter “” (two double quotes) in the Initial value field. Leave the rest ofthe check boxes unselected.

__Click Add

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 6 of 45

Page 7: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ and then click Close.

__ Select Next.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 7 of 45

Page 8: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ In the EJB Attributes window, click Add Package... and add javax.ejb to the list ofimport statements to the bean class. Verify the information below.

__4. Click Finish. The CMP entity bean classes will be generated.

The Account bean should appear under EJB Modules and YourBankEJBModule inthe J2EE view. Verify the items Account, AccountBean, AccountHome and AccountKeyappear under the Account bean as illustrated below.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 8 of 45

Page 9: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__5. Next you will need to create a custom exception to be called when the balance is lessthan zero for the account.

__ From the main menu select File --> New --> Other. In the window of differentwizards select Java and Java Class. Click Next.

This will launch the Create new Java class wizard.

__ Fill in or Browse to /YourBankEJBModule/ejbModule for the Folder.

__ Fill in com.ibm.yourbank.exception for the package.

__Name the file InsufficientFundsException.

__ For the Superclass, click Browse...

__ In the Superclass Selection window, enter exception in the top field.

__ Select Exception in the list and click OK.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 9 of 45

Page 10: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Check the Constructors from superclass.

__ Click Finish.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 10 of 45

Page 11: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__6. The file InsufficientFundsException.java which you just defined will be displayed in theeditor view. Close the file and insure you are in the J2EE view of the J2EE Perspective.Expand EJB Modules --> YourBankEJBModule --> Account.

__7. Open the AccountBean.java file by right clicking on AccountBean and selecting Openwith-> Enterprise Bean Java Editor. Make the following changes:

__ After the package declaration, add the following import statement to include theInsufficientFundsException just created.

import com.ibm.yourbank.exception.InsufficientFundsException;

__ Scroll to the bottom of the file and after the setBalance method add the following code: (NOTE: To save time, copy the code in the file c:\yourbank\lab1\snippet1.java to the fileAccountBean.java).

/** * Initialize fields in account. */public void accountInitialize(int type, float balance, String

accountOwner) throws javax.ejb.CreateException, javax.ejb.EJBException {this.type = type;this.balance = balance;this.accountOwner = accountOwner;

}

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 11 of 45

Page 12: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

/* adds the specified amount to the account balance and returns * the new balance */ public float add(float amount) { balance += amount; return balance; }

/* subtracts the specified amount from the account balance and * returns the new balance */ public float subtract(float amount) throws InsufficientFundsException { if(balance < amount) { throw new InsufficientFundsException ("Insufficient funds"); } balance -= amount; return balance; }

Notice the * next to the name of the filename in the Editor view. The * indicates that thefile has been changed.

__ Save the file after you add the three methods by selecting File --> Save. You shouldsee the add(float) and subtract(float) methods in the Outline pane under theAccountBean.

__8. After both methods have been added to the bean, you will need to add them to the remoteinterface. Only methods in the Account Remote interface are visible to the client.

__ If AccountBean.java has been closed, open the file.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 12 of 45

Page 13: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Go to the Outline view and select these methods (accountInitialize, add andsubtract) you have just created. You may hold down the Ctrl key as you select in orderto select multiple methods at one time.

__ Once the methods are selected, right mouse click and select: Enterprise Bean,Promote to Remote Interface. The methods, accountInitialize, add, and subtract, arenow available for the client to use.

NOTE: If you do not see the Enterprise Bean option in the right click menu, make sure youhave opened AccountBean from the J2EE view of the J2EE Perspective. Simply switching tothe J2EE view with the file AccountBean.java open will not display the Enterprise Bean option.The AccountBean must be opened while the J2EE view is selected. Promoting methods tothe remote interface is a J2EE operation and it is fitting to have this function only available inthe J2EE view. If you still have difficulties promoting the methods to the remote interface, thenmanually add the following method declarations (also available atc:\yourbank\lab1\snippit2.java) to the Remote Interface file Account.java:

public void accountInitialize(int type, float balance, String accountOwner)throws javax.ejb.CreateException, javax.ejb.EJBException,java.rmi.RemoteException;

public float add(float amount) throwsjava.rmi.RemoteException;

public float subtract(float amount) throws InsufficientFundsException, java.rmi.RemoteException;

__9. An entry should be added to the Task view indicating that InsufficientFundsExceptioncannot be resolved. Double-click the entry and the file Account.java will open in the Javaeditor. At the top of the file, add the following line below the package statement to includethe InsufficientFundsException.

import com.ibm.yourbank.exception.InsufficientFundsException;

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 13 of 45

Page 14: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Verify that all the business methods have indeed been promoted. Scroll to the bottomof the file and notice the accountInitialize, add, and subtract methods have been added.Because this is an interface you will only see the methods declarations.

__ Save and Close the file.

__10. Next it is necessary to map fields in the Account EJB to columns in the database. Sinceyou have already defined the Account EJB, you will use the Top Down mapping strategyto define the columns in the database.

__ Select YourBankEJBModule under EJB Modules in the J2EE view.

__ Right-click and select Generate EJB to RDB Mapping.

__ This will bring up the Create new EJB/RDB Mapping Smart guide. Make sure thatthe Top Down radio button is selected and then click Next to go to the next page.

__ In the Target Database field, verify DB2 UDB V7.2. is selected.

__ In the Database Name field, enter BankData.

__ In the Schema name field, enter NULLID.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 14 of 45

Page 15: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Check the Generate DDL check box.

__ Click Finish.

__11. Verify that the schema and map files were created. In the Navigator window check thatSchema/Schema.dbxmi and Map.mapxmi are in the ejbModule\META-INF folder ofthe YourBankEJBModule (here you can also find the deployment descriptor file ejb-jar.xmlwhich contains all of the information regarding the Account EJB).

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 15 of 45

Page 16: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ You can view the EJB/RDB Mapping by opening the Map.mapxmi file in the Map editor by double-clicking on the filename and examine the EJB/RDB Mapping for YourBankEJBModule.

Part Three: Entity Bean Deployment and testing in the WebSphere Application ServerV4.0 Unit Test environment

At this point you should verify that your Account Entity Bean performs correctly. To dothis, you need to create a database, create a database table, indicate a datasource nameto your enterprise bean, define a datasource to the server environment, generatedeployed code, and start your enterprise bean in the WebSphere Application Server V4.0Test environment. For your testing, you will create your own instance of the Test server.

Create the Application Database in DB2

__1. In preperation for creation of the Application database and the DataSource, we will use aspecific user account. Many times it is best to use a generic account rather than anaccount owned by a specific user. The generic account you will create in the Windowsoperating system is USERID, and the Password is PASSWORD. If you have anexisting userid you wish to use, such as the userid you are currently logged in as, you willneed to replace USERID and PASSWORD with those values where appropriate below.

__ Click the Windows Start button, and select Programs --> Administrative Tools(Common) --> User Manager for Domains. (On NT Workstation, User Manager)__ In the User Manager window, click to select Username Guest.__ Click the User menu, and select Copy. In the Copy of Guest window, fill in:

Username: USERIDFull Name: WebSphere LabDescription: DB2 User for MyBank ApplicationPassword: PASSWORDConfirm Password: PASSWORD

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 16 of 45

Page 17: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Click Add. Click Close. (or Cancel on NT Workstation.) Exit the User Manager.

__2. Create the BankData database that you specified during your top-down mapping of thefields in the Account EJB.

__ Open a DB2 Command Window by clicking on Start-->Programs-->IBM DB2-->Command Window.

__ Type the command: db2 create db BankData.

__3. With the database created, now you can create the table in the database to hold Accountinformation. When you created the EJB to RDB mapping, the SQL statement to createthe Account table was also created.

__ From the DB2 command window, change to the <WSAD root directory> \YourBankEJBModule\ejbModule\META-INF directory. (For example C:\ProgramFiles\IBM\Application Developer\workspace\YourBankEJBModule\ejbModule\META-INF)

__ Execute the following commands to create the table from the table.ddl file created when specifying the top-down mapping. db2 update db cfg for BankData using applheapsz 256 db2 connect to BankData db2 grant createtab, connect on database to user USERID

This grants basic database privileges to the User you just created. db2 connect reset

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 17 of 45

Page 18: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

db2 connect to BankData user USERID using PASSWORD This allows you to create the database tables under the schema for USERID.

db2 -tf Table.ddl

Ignore any message saying that the Schema DB2ADMIN or the table DB2ADMIN.ACCOUNT already exists. __ You will populate the table with a couple of rows of data. Add a row to the ACCOUNTtable by typing in the following commands from the Command Line Processor window(To save time, from the DB2 command window you can run the commandc:\yourbank\lab1\populate.bat):

db2 insert into account(accountnumber, type, balance,accountOwner) values(1, 1, 15.15, ‘Tester, Joe’)

db2 insert into account (accountnumber, type, balance, accountOwner) values(2, 1, 30.15, ‘User, Jane’)

__ Verify that your data was correctly loaded into DB2 by executing the followingcommand:

db2 select * from account

You should see two records listed.

__ Bind the application to the database (The db2cli.lst file contains the list of bind (.bnd)files required to create packages for the DB2 CLI and the DB2 ODBC driver. )

cd c:\sqllib\bnddb2 bind @db2cli.lst blocking all grant publicdb2 connect reset

__ Type Exit to close the DB2 Command window

__4. With the database defined, now you need to define the datasource that the Account EJBwill use to store accounts. You will also need to specify the JNDI name the Account EJBwill use when referencing the datasource.__ To define a datasource name to your EJB, go to the Navigator View, then toYourBankEJBModule/ejbModule/META-INF. Right mouse click the ejb-jar.xml file,

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 18 of 45

Page 19: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

then select Open with-->EJB Extension Editor.

__ Select the Binding tab in the EJB Extension Editor (the tab is located at the bottom of the Editor view).

__ Expand YourBankEJBModule and click the Account Bean.

__ In the right pane, indicate the JNDI Name for the Account EJB is ejb/Account, and forthe Datasource indicate that the JNDI name is jdbc/YourBank.

__ Save and Close the file.

__5. Before running your entity bean in WebSphere Application Server, specify theDatasource for your entity bean. You will have to use the same names as you used instep 3 when you defined the JNDI Datasource name to your entity bean.

__ Select Perspective --> Open --> Server. The Server Perspective is commonlyused when working with the WebSphere v4.0 Test Environment. Notice another icon forthe Server perspective is added to the list of perspectives on the left.

__ Create a Server Project by clicking on File-->New-->Server Project. (There also isan icon on the toolbar to perform the same action.)

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 19 of 45

Page 20: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ On the Create a New Server Project wizard, indicate that your server project shouldbe named TestServer, and leave the default location checked for the location of theproject. Click Finish.

__ Add a server instance and server configuration. Click File-->New-->Server Instanceand Configuration as shown below.

__ On the Create a new server instance and configuration wizard, indicate the Server name is YourBankServer and use TestServer for the Server project folder.

__ Expand WebSphere Servers and choose WebSphere v4.0 Test Environment forthe server instance type and click Next.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 20 of 45

Page 21: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ On the WebSphere Server Configuration Settings, accept the Server port number of8080 and select Finish.

__ In the Server Configuration View, expand Server Configurations, and double clickYourBankServer.

__ In the Editor view, select the Datasource tab at the bottom of the view. Click theDatasource tab, then select Db2JdbcDriver(COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource) in the JDBC Driver List.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 21 of 45

Page 22: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

Note: If your DB2 zip file containing the DB2 Java classes is not on c:/programfiles/sqllib/java/db2java.zip, you will have to select the Edit button on the Db2JdbcDriver inthe JDBC Driver List and indicate the correct path to the db2java.zip file.

__ Click Add... to the right of Datasources defined in the JDBC driver selectedabove.

__ In the Add a Datasource panel, indicate Name as YourBankData, JNDI name asjdbc/YourBank, and Database name as BankData. Enter the word “userid” as thedefault userid and the word “password” as the password.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 22 of 45

Page 23: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

click OK.

__ Save the file, YourBankServer, and close it.

__5. Your EJB application must be specified to run on a server. You will need to add theapplication to the configuration of the server you just created.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 23 of 45

Page 24: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ In the Sever Perspective, Server Configuration View, under Server Configurations, right mouse click YourBankServer and select Add Project --> YourBankEAR.

Your application is now able to run on the test server you created.

__ Verify that YourBankServer is the preferred server for YourBankEJBModule. Go tothe Navigator View of the J2EE perspective. Right mouse click YourBankEJBModule,select Properties, then select Server Preference. Verify that YourBankServer isselected and click Apply. Click OK to dismiss the properties dialog.

Although you added your application to the server configuration in the last step, youneed to specify a preferred server where the application should run. With the abilityto add a project to a multiple configurations and then specify a particular server, youcan have an application available to multiple servers, but run on a certain server bydefault.

__6. Before the EJB can be tested, code used by the EJB Container to support running of theapplication must be created. Creating this code is referred to as deploying the code.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 24 of 45

Page 25: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Go to the J2EE perspective, J2EE View, expand EJB Modules, right mouse clickYourBankEJBModule and select Generate -> Deploy and RMIC code.

__ From the Deploy, and RMIC, selected enterprise beans(s) wizard, verify the Account bean is checked and click Finish.

__7. After the code is deployed, you can test your Account Entity Bean. Start the AccountEntity Bean in the WebSphere Application Server V4.0 Unit Test environment on theserver you just created.

__ In the Server Perspective, Server Control Panel view, select the Servers. (tab at the bottom).

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 25 of 45

Page 26: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Right-click the Server Instance YourBankServer and select Start to start your WebSphere Application v4.0 Test Environment.

If the Console view is not switched to automatically, select the Console view (tab at thebottom) to watch your server start. Wait until the message Default Server open fore-business is displayed.

__ In the Navigator View of the Server Perspective, right mouse clickYourBankEJBModule, and select Run on Server. This will start the WebSphere Application Server V4.0 Unit Test environment. The IBM EJB Test Client will also be started in the Browser View.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 26 of 45

Page 27: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__6. Testing Your Account Entity Bean using the IBM EJB Test Client

__ The IBM EJB Test Client is normally started in the Browser View of the ServerPerspective when you start a Server. If it wasn’t started, just type http://localhost:8080/UTC in the browser view and click the GO icon.

__ To test your EJB in the IBM EJB Test Client, click JNDI Explorer in the EJB TestClient and the JNDI Explorer will appear as shown below (it may take up to 30seconds).

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 27 of 45

Page 28: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Expand ejb and click Account (com.ibm.yourbank.ejb.AccountHome_Stub).

__ Expand EJB References in the References view until you see Account findByPrimaryKey(AccountKey).

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 28 of 45

Page 29: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Click Account findByPrimaryKey(AccountKey) and you will see the Parameters frame change.

__ Click the down arrow of the rightmost symbol in the Paramter/Value box, and thenselect com.ibm.yourbank.ejb.AccountKey(long).

__ Enter 1 for the value and click Invoke and Return. This passes a 1 to theconstructor of the AccountKey class.

__ In the Parameters frame click Invoke.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 29 of 45

Page 30: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

This passes the AccountKey object to the findByPrimaryKey() method of the EJBhome interface.

__ At this point you should see an Account object in the Results area. Select Work withObject.

You will see the EJB References tree in the References section update. If you expandAccount (com.ibm.yourbank.ejb.AccountKey@1), you will see the EJB’s remote interface methods.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 30 of 45

Page 31: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Click the float getBalance() method. The Parameters area of the display will updateand display the float getBalance() method. Click Invoke in the Parameters pane to seethe balance in the Results Area.

__ In the Results frame, the balance for account 1 should be displayed. This indicates your EJB is working correctly. Close the Web Browser.

__ Still in the Server Perspective, go to the Server Control Panel view, right-clickYourBankServer, then select Stop to end your test server.

Part Four: Creating the Transfer stateless session EJB

__1. Add a new session bean to the EJB module.

Switch to the J2EE perspective and from the main menu select File-->New-->,

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 31 of 45

Page 32: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

Enterprise Bean or click the Create an Enterprise Java Bean toolbar button. This willlaunch the new Enterprise Java Bean wizard.

__ Name the bean Transfer.

__ Select Session bean as the Bean type. (Default)

__ Browse to the EJB project YourBankEJBModule.

__ The Default package root should be set to ejbModule.

__ Provide the package name for the generated classes by entering com.ibm.yourbank.ejb into the Bean class field. (In front of TransferBean) Verify that it propagates to the other fields.

__ Click Next.

__ On the next page add javax.ejb, javax.naming, javax.rmi and java.rmi to the list ofimport statements required for the bean class. (Hint: Use the Add Package button).

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 32 of 45

Page 33: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Click Finish to generate the Session bean classes.

__2. With the Transfer Enterprise Java Bean created, you will next need to add someadditional methods. In the J2EE view of the J2EE perspective, open TransferBean inthe Java editor.

__ Add the following import statement to the class.

import com.ibm.yourbank.exception.InsufficientFundsException;

__ Add the following field at the beginning of the class. It will be used during a transferoperation.

private AccountHome accountHome = null;

__ Add the following methods to the TransferBean class. (NOTE: To save time, copythe code in the file c:\yourbank\lab1\snippit3.java to the file TransferBean.java).

/** * Returns the balance of the account identified by the acctId * parameter */ public float getBalance(long acctId) throws javax.ejb.FinderException { AccountKey key = new AccountKey(acctId); Account fromAccount; try { fromAccount = accountHome.findByPrimaryKey(key); return fromAccount.getBalance(); } catch (FinderException ex) { throw new FinderException("Account " + acctId + "does not exist"); } catch (RemoteException ex) { throw new EJBException("Cannot get balance for " + acctId); } }

/** * Transfers the specified amount from the fromAcctId account * to the toAcctId account; throws InsufficientFundsException * if the account identified by the fromAcctId contains less * than the amount requested for tranfer. */ public void transferFunds(long fromAcctId, long toAcctId, float amount) throws InsufficientFundsException, javax.ejb.FinderException { AccountKey fromKey = new AccountKey(fromAcctId); AccountKey toKey = new AccountKey(toAcctId);

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 33 of 45

Page 34: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

Account fromAccount, toAccount; try { fromAccount = accountHome.findByPrimaryKey(fromKey); toAccount = accountHome.findByPrimaryKey(toKey); toAccount.add(amount); fromAccount.subtract(amount); } catch (FinderException ex) { throw new FinderException("Account " + fromAcctId + " does not exist."); } catch (RemoteException ex) { throw new EJBException(); } catch (InsufficientFundsException ex) { mySessionCtx.setRollbackOnly(); throw new InsufficientFundsException ("Insufficient funds in " + fromAcctId); } }

/** * Gets the home object for the CMP Account EJB using ejb * references. This method returns a reference to the * AccountHome object when the bean is being created. */ public AccountHome getHome() { try { InitialContext initCtx = new InitialContext(); Object objref = initCtx.lookup("java:comp/env/ejb/Account"); return (AccountHome)PortableRemoteObject.narrow (objref, AccountHome.class); } catch (NamingException ne) { ne.printStackTrace(); throw new EJBException ("Error looking up AccountHome object: " + ne.getMessage()); } }

__ Add the following line of code to the ejbCreate() method of TransferBean.java.

accountHome = getHome();

__ You should see the getBalance(long), transferFunds(long, long, float) andgetHome() methods in the Outline pane under the TransferBean. Save the file after youadd all the methods.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 34 of 45

Page 35: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__5. After all the methods have been added and their implementation saved in the TransferBean class, you will need to add getBalance and transferFunds to the remoteinterface. Only methods in the Transfer remote interface are visible to the client.

__ Insure that you are still in the J2EE view in the J2EE Perspective. To add the abovemethods to the remote interface make sure that the TransferBean is opened in the Java editor. Select getBalance and transferFunds in the Outline window. You may hold down the Ctrl key as you select in order to select multiple methods at one time. Once the methods are selected, right mouse click and select: Enterprise Bean,Promote to Remote Interface.

NOTE: If you do not see the Enterprise Bean option in the right click menu, make sure youhave opened TransferBean from the J2EE view of the J2EE Perspective. Simply switching tothe J2EE view with the file TransferBean.java open will not display the Enterprise Bean option.The TransferBean must be opened while the J2EE view is selected. Promoting methods tothe remote interface is a J2EE operation and it is fitting to have this function only available inthe J2EE view. If you still have difficulties promoting the methods to the remote interface, thenmanually add the following method declarations (also available atc:\yourbank\lab1\snippit4.java) to the Remote Interface file Transfer.java:

public float getBalance(long acctId) throws

javax.ejb.FinderException, java.rmi.RemoteException ; public void transferFunds(long fromAcctId, long toAcctId, float amount) throws InsufficientFundsException, javax.ejb.FinderException, java.rmi.RemoteException ;

__6. An entry should be added to the task view indicating that InsufficientFundsExceptioncannot be resolved. Double-click the entry and the file Transfer.java will open in the Javaeditor. At the top of the file, add the following line below the package statement to includethe InsufficientFundsException.

import com.ibm.yourbank.exception.InsufficientFundsException;

__ Save the file.

__ Verify that all the business methods have indeed been promoted. Scroll to the bottomof the file and notice the getBalance and transferFunds methods have been added.Because this is an interface you will only see the methods declarations.

__ Close the file.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 35 of 45

Page 36: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

Part Five: Testing the Transfer Session EJB

At this point you can verify that both of your EJBs perform correctly. First you will need tospecify a reference to the Account EJB and then a JNDI name for your Transfer EJB.Next you will verify your application to be J2EE compliant. Then you need to generateDeploy code for your session bean. Finally, you need to start your enterprise bean in theWebSphere Application Server V4.0 Unit Test environment. You will create a new UnitTest environment based off the configuration you created when testing the Account bean.With the new server created, you can test the Transfer session bean with the IBM EJBTest Environment.

__1. Specify a reference to the Account EJB for the Transfer EJB.

__ In the Navigator view of the J2EE Perspective, expandYourBankEJBModule\ejbModule\META-INF\.

__ Right click the file ejb-jar.xml and select Open With --> EJB Editor.

__ Click the References tab and select the EJB References radiobutton. The Accountand Transfer EJBs should be listed.

__ Click the Transfer EJB Bean and click Add.

__ For the Name, enter ejb/Account.

__ For the Type, select Entity.

__ For the Home, enter com.ibm.yourbank.ejb.AccountHome.

__ For the Remote, enter com.ibm.yourbank.ejb.Account.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 36 of 45

Page 37: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ For the Link, enter Account.

__ Select OK.

__ Save and Close the file.

__2. Specify a JNDI name for the Transfer EJB.

__ Right click the file ejb-jar.xml and select Open With --> EJB Extension Editor.

__ Click the Binding tab and expand YourBankEJBModule.

__ Select Transfer and in the JNDI name field enter ejb/Transfer. Since this is asession bean a datasource is not specified for the EJB.

__ Expand YourBankEJBModule\Transfer and select EjbRef ejb/Account.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 37 of 45

Page 38: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ In the JNDI name field, enter ejb/Account.

__ Save and Close the file.

__3. Next you will verify your code to be J2EE compliant. Right click the YourBankEJBModuleand select Run Validate.

WebSphere Studio Application Developer will validate the project based on the J2EE v1.2specification. Any mappings of EJB fields contained in the YourBankEJBModule are alsovalidated. If there are parts of your application that do not meet the spec, they will belisted in the Tasks view of the perspective.

You can determine what you want validated by setting the appropriate Validation optionsunder the Project properties.

__4. In the J2EE Perspective, J2EE View, right mouse click YourBankEJBModule, thenselect Generate -->Deploy and RMIC Code.... From the Deploy, and RMIC, selectedenterprise bean(s) wizard, select the Transfer bean and click Finish.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 38 of 45

Page 39: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__5. The code is now ready to run on the WebSphere Application Server v4.0 Unit Testenvironment. Even though you could test your EJB application on the server you createdbefore, you will create another server configuration based on the first server to test yourEJBs. With multiple server configurations, you can easily switch the testing of yourapplications between different settings.

In WebSphere Studio Application Developer v 4.0, there is a bug when creating a testserver from a template. This problem should be fixed with Fix Pack 1 (4.0.2). Skip to step6 and use YourBankServer to test the Session bean.

To create another configuration, first you will create a template based on the existingserver’s settings. The template will contain the datastore information that you defined inPart Three, reducing the time it takes to set up the new Unit Test server.

__ From the Window menu, select Preferences.

__ In the Preferences window, expand Server and select Defaults and Templates.

__ Select Add Template.

__ In the Create a New Server Template window, give the template a name of YourBank Template with a description of Template for testing the YourBank Application.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 39 of 45

Page 40: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ Expand Server Configurations and select YourBankServer.

__ Click Finish.

__ Click OK to close the Preferences window.

__ With the template created, now you can create your Unit Test server. Go to theServer Perspective and select the Create Server Instance and Configuration button.

__ Enter a Server name of YourBankServer2 and expand WebSphere Servers and select WebSphere v4.0 Test Environment.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 40 of 45

Page 41: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ In the Server configuration type section, select YourBank Template as the template.

__ Click Finish.

__ In the Server Configuration view, right-click and select Edit on YourBankServer2.Since you created the template from the server instance where you had defined theYourBank datasource, the YourBankServer2 will also have this datasource defined,saving configuration time. Switch to the Datasources tab and notice the YourBankDataDatasources is defined. Close the Server Configuration when you are finished.

__ With your new Test server defined, you need to specify this server as the preferred server for running your YourBankEJBModule project. In the Navigator view ofthe Server Perspective, right-click the YourBankEJBModule project and select

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 41 of 45

Page 42: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

Properties.

__ In the Properties for YourBankEJBModule window, select Server Preference from the list on the left and select YourBankServer2.

__ Click Apply and then click OK.

__6. The YourBankServer2 is ready to be started. Start the server by going to the Serversview in the Server Perspective and selecting Start from the right-click menu.

__7. With the server started, you can test your Transfer Session Bean using the IBM EJB TestClient.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 42 of 45

Page 43: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

__ In the Navigator view of the Server Perspective, right-click the projectYourBankEJBModule and select Run on Server.

__ To test your EJB in the IBM EJB Test Client, click JNDI Explorer and the JNDIExplorer will appear.

__ Expand ejb and click Transfer, then expand EJB References in the Referencesview until you see Transfer create().

__ Click Transfer create() and you will see the Parameters area change. Click Invokein the Parameters area.

__ At this point you should see an Transfer Object in the Results area. Click Workwith Object to narrow the object to the appropriate type and get back a reference to theEJB home interface. You will see the EJB References tree in the References sectionupdate.

__ If you expand Transfer (1), you will see the EJB’s remote interface methods. Clickthe float getBalance(long) method. The Parameters area of the display will updateand display the float getBalance(long) method.

__ Supply a value of 1 for Value and click Invoke. You should then see the balance inthe Results area. Your EJB is working correctly.

__8. From the Server Perspective, stop your server environment by going to the ServerControl Panel view, right clicking on YourBankServer2, and then selecting Stop.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 43 of 45

Page 44: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

Loading the Lab1 Solution :

__1. From a DOS window run the file C:\yourbank\solutions\lab1\CfgLab1.bat

__2. Import the Server Configurations

__ File->New->Project... Server, Server Project, click Next __ Enter the project name TestServer, click Finish. __ File->Import. Select Zip file, click Next __ Browse to C:\YourBank\Solutions\Lab1\TestServers.zip __ Enter "TestServer" as your Folder name __ Click "Finish"

*NOTE* The Test Servers imported assume default directory structure. If you have used different directory structure than the defaults, you will have to configure the servers manually as found in Section 3 of Lab 1.

__3. Import yourBankAfterLab1.ear file into Application Developer.

__ File -> Import

__ Click Next

__4. Application Developer is ready.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 44 of 45

Page 45: Developing Enterprise JavaBeans - IBMEnterprise Javabeans or EJBs commonly contain the business logic of an application and are combined with Servlets, JSPs, and client applications

What you did in this exercise

In this exercise, you created both an Entity Bean and a Session Bean and tested them in theWebSphere v4.0 Test environment. You created a DB2 table to back the Entity Bean and storeaccount information for the YourBank application. You tested both of your EJBs in theWebSphere Application Server V4.0 Test environment and created a server configuration off of atemplate.

© Copyright IBM Corporation 2001. All rights reserved.

2002/01/14 08:42:58 IBM WebSphere Studio Application Developer Workshop - Lab Exercise appdevl1.lwp Page 45 of 45