This workshop will show you the process of migrating an application from WebSphere Studio Application Developer 4.0 to 5.0. The WBOnline Banking Application will be used to demonstrate the migration process. This workshop is divided into three parts:
In Part I, we will take a look at how we can run an existing J2EE 1.2 Application, WBOnline, in WebSphere Studio Application Developer 5.0 (hereafter called Application Developer). Moreover, the new WebSphere log analyzer tools will also be introduced in this workshop. The last section of this lab will explain what has changed in the servlet code for the WBOnline Application in preparation for the other parts of this workshop.
Note: This workshop requires
that the following products are installed:
|
The first thing we need to do is import an existing WBOnline Application which is compliant to J2EE 1.2 into Application Deveoper 5.0.
___ 1. Import WBOnline.ear
a. If not already started, start WebSphere Studio Application Developer.b. Choose File->Import... from the menu bar.
c. From the Import dialog, select EAR file and click Next> .
d. From the Enterprise Application Import dialog, specify the following:
Parameter Value EAR File x:\WS50STEW\hands-on\Migration\Part_I\WBOnline.ear Project name WBOnlineEAR Use default checked
![]()
e. Select Next> and then Next> and then Next> .
f. From the Import - Manifest Class-Path dialog, choose WBOnline.war from the left hand pane. Make sure the checkbox for WBOnlineEJB.jar is checked in the right-hand pane. This way, WBOnlineEJB will be added to the Java Build Path and the manifest file correctly.
![]()
g. Click Finish.
You should see the following in the Navigator view.
![]()
Application Developer 5.0 supports the WAS 4.0 Unit Test Environment. We will setup the test server and configuration and run the WBOnline Application in this section.
___ 1. Open a Server Perspective
a. From the Perspective bar, open a Server Perspective by clicking on the Open Perspective icon:
![]()
b. From the popup menu, select Other....
c. From the Select Perspective dialog, select Server and click OK.
___ 2. Create a Server Project
a. From the Open New Wizard dropdown arrow button, select Other... from the pop-up menu.___ 3. Create a new Server and Server Configuration
![]()
b. From the New Wizard dialog, select Server from the left-hand pane, and Server Project from the right-hand pane.
Click the Next> button.
c. In the Create a new Server Project Wizard, specify a Project name of Servers.
Click the Finish button.
a. Choose File->New->Server and Server Configuration from the menu bar.___ 4. Add the jdbc/AIS DataSource to the WebSphere 4.0 server configurationb. From the Create a new server and server configuration wizard, specify the following:
Parameter Value Server name WebSphere v4 Unit Test Folder Servers Server type WebSphere version 4.0 Test Environment Template None WebSphere configuration template None
![]()
Click the Next> button.
c. Verify a HTTP port number of 8080.
d. Click the Finish button.
This will create a new server and server configuration.
a. From the Server Configuration view, expand Server Configurations and select WebSphere v4 Unit Test. (Note: By default, this is in the lower left-hand corner of the workbench)
![]()
b. Click mouse button 2, and choose Open from the pop-up menu. This will launch the server configuration editor in the source view.___ 5. Start the Unit Test Serverc. From the WebSphere v4 Unit Test configuration editor, click on the Data source tab.
d. From the JDBC driver list, highlight the Db2JdbcDriver driver and click the Edit... button.
e. Verify that the Classpath contains the correct path to db2java.zip.
![]()
Click the OK button.
f. With the Db2JdbcDriver selected, click the Add... button to the right of the Data source defined in the JDBC driver selected above.
g. From the Add a Datasource dialog, specify the following:
Parameter Value Name AIS JNDI name jdbc/AIS Database name AIS
![]()
Click the OK button.
The Data sources should look similar to this: (Note: You may see a Session Persistence datasource in the list as well)
![]()
h. Hit Ctrl+S to save the changes.
i. Close the WebSphere v4 Unit Test configuration editor by clicking on the close icon:
![]()
a. From the Server Configuration view, select the WebSphere v4 Unit test configuration, click mouse button 2, and choose Add->WBOnlineEAR from the pop-up menu.___ 6. Test WBOnlineb. From the Servers view highlight the WebSphere v4 Unit Test server, click mouse button 2, and choose Start from the pop-up menu.
![]()
This will publish the project and start the server. After a few moments, check the console window. You should see a message saying Default Server open for e-business. You should scroll through the console to verify the EJB jar WBOnline was started. It should look similar to this :
![]()
a. From the Navigator view, expand the WBOnline and Web Content folders. Highlight Index.html and click mouse button 2 :___ 7. Stop the Server
![]()
Choose Run on Server from the pop-up menu.
![]()
b. From the Server selection dialog, select the WebSphere v4 Unit Test Server.
![]()
Click the Finish button.
Tip: You can reset the server preference from the Properties settings of each project. Click mouse button 2 on the project in the Navigator view and choose Properties :
![]()
The internal browser should be loaded up with the Index.html page.
![]()
d. From the Index.html page, click on the Online Account Activity link.
e. Enter "1" for the WEBBank Customer Number entry field and press Submit.
f. It should show a list of accounts for customer #1.
![]()
Click on one of the account numbers. You should see a list of transactions for that particular account.
![]()
a. Close the WEB Browser.b. Switch from the Console view to the Servers view from the bottom of the workbench:
![]()
c. Highlight the WebSphere v4 Unit Test Server, click mouse button 2, and choose Stop from the pop-up menu.
We have tools which can analyze the activity log to help identify problems. If you need to determine why an exception or error has occurred in the workbench, you can import the XML log file that is generated by the workbench into the Profiling perspective and check it. Viewing the log files using the Logging tools capitalizes on the visual organization of large quantities of data and the ease of navigation that is afforded by the Log views. WebSphere Activity log entries can be analyzed using an XML symptom database to interpret known events and error conditions.
___ 1. Import a Symptom Database File
a. Choose File->Import... from the menu bar.
b. From the Import dialog, select Symptom Database File and click Next>.
c. From the Symptom Database File dialog, specify the following:
Parameter Value Local host <WSADInstall>\runtimes\aes_v4\properties\logbr\symptoms\std\symptomdb.xml Location LogAnalyzerProject File symptomdb.trcdbxmi The LogAnalyzerProject doesn't exist yet but it will be created after this step.
![]()
Click the Finish button.
___ 2. Load the WebSphere Activity Log
a. From the Server Perspective, click mouse button 2 on the WebSphere v4 Unit Test Server in the Servers view.
![]()
b. Choose Show Activity Log....
![]()
c. From the Import WebSphere Application Server Log File - Destination dialog, click Next>.
d. From the Import WebSphere Application Server Log File - Location dialog, click Next>. (Note the default location of the activity.log file.)
e. From the Import WebSphere Application Server Log File - Host dialog, click the Finish button. The Profiling Perspective will be opened with your activity log highlighted in the Monitors view
![]()
___ 3. Load the Symptom Database
a. From the Monitors view, click mouse button 2 on the Activity log entry and choose Show View->Activity Log .
b. From the Activity Log view, click mouse button 2 on one of the Log Records and choose Load Symptom Database... .
c. From the Load Symptom Database dialog, click the Add Database... button.
d. From the Symptom Database dialog, select symptomdb.trcdbxmi from the LogAnalyzerProject Project and click OK. And click OK again to finish.
e. Click the Finish button.
___ 4. Use the Activity Log View
a. From the Activity Log View, click mouse button 2 on one or more of the Log Records and choose Analyze.
If there is a match between the log entry and the symptom database, detailed information (reasons for the error and suggested recovery steps) regarding the log entries will be shown in the Analysis Result View.
![]()
If you want to analyze other WebSphere log files, choose File->Import...->WebSphere Log File to import them into the workbench for analysis purposes.
Tip:
1. Different icons represent the different level of severity of the log entry and whether a match is found against the database.
Icons What it means ![]()
information ![]()
warning ![]()
error (opaque)
entry found in the symptom database (transparent)
entry not found in the symptom database
2. The log records can be sorted (click theicon) and filtered (click the
icon).
___ 5. Close the Profiling Perspective
a. From the Perspective bar, Select the icon which represents the Profilng perspective, click mouse button 2, and choose Close from the pop-up menu.
b. On the Profiling Message message box that pops up asking if you want to save the projects, click the Yes button.
In preparation for migrating WBOnline Web Application from J2EE 1.2 standard to J2EE 1.3 standard, the original servlets code have been migrated from older versions of WBOnline beforehand. You will not make any changes to the source code in this section since it has already been changed. This section is here so you understand what has been changed in WBAccountActivity and WBTxnActivity servlet classes from previous versions of WBOnline.
___ 1. PageListServlet replaced with HTTPServlet
a. The original servlets code in older versions of WBOnline were generated from WebSphere Studio 3.0. PageListServlet was based on Servlet API 2.2. As we migrate to J2EE 1.3, the servlets code need to be compliant with Servlet API 2.3 standand. Therefore, we should inherit from HTTPServlet and not PageListServlet
Change #1 we made:
For WBAccountActivity.java, we replaced:
public class WBAccountActivity extends PageListServlet implements Serializable
with:
public class WBAccountActivity extends HttpServlet implements Serializable
Change #2 we made:
Similarly for WBTxnActivity.java, we replaced:
public class WBTxnActivity extends PageListServlet implements Serializable
with:
public class WBTxnActivity extends HttpServlet implements SerializableChange #3 we made:
b. We removed the import statement from both WBAccountActivity.java and WBTxnActivity.java :
Remove this:
import com.ibm.servlet.*;c. New methods were created to support the methods that were from PageListServlet:
/*****************************************************************************
* Redirect to the correct page
*
* @param url name of the redirected page
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void callPage(String url, HttpServletRequest request, HttpServletResponse response)
{
try {
response.sendRedirect(url + ".jsp");
} catch (IOException ioEx) {
handleError(request, response, ioEx);
}
}
/*****************************************************************************
* Get the correct page name
*
* @param request Object that encapsulates the request to the servlet
* @return The page name
*/
public String getPageNameFromRequest(HttpServletRequest request)
{
String url = getServletConfig().getServletName() + "Results";
return url;
}
/*****************************************************************************
* Handle Exceptions
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
* @param ex The exception thrown
*/
public void handleError(HttpServletRequest request, HttpServletResponse response, Throwable ex)
{
ex.printStackTrace();
}These methods are added to both WBAccountActivity.java and WBTxnActivity.java.
Change #4 we made:
___ 2. callPage() is used instead of callPageNamed()
In the performTask() method of WBAccountActivity.java, we replaced:
callPageNamed("WBInvalidCustomer", request, response);
with:
callPage("WBInvalidCustomer", request, response);
Congratulations, you've completed Part I of the migration workshop! Part II of the workshop will focus on running WBOnline (J2EE 1.2) with WAS 5.0 Test Environment.