WebSphere Studio Application Developer Version 5 Programming Guide part 57 potx

10 212 0
WebSphere Studio Application Developer Version 5 Programming Guide part 57 potx

Đang tải... (xem toàn văn)

Thông tin tài liệu

534 WebSphere Studio Application Developer Version 5 Programming Guide Figure 15-19 Defining an authentication entry On the Data source page, open the EJBBANK data source and set the authentication alias (Figure 15-20). Save the configuration. Figure 15-20 Using the authentication for a data source Chapter 15. Servers and server configurations 535 Starting and stopping servers To run your application, you can either select Run on Server from the context menu of its project (as shown in Figure 15-1) or you can manually start the server associated with your application. If you select Run on Server , the server will be started for you automatically. To start a server manually, select the WebSphere v5.0 on vertex (Copy) server in the Server Configuration view or in the Servers view (Figure 15-21):  In the Server Configuration view, select Control -> Start (context)  In the Servers view, select Start (context). Figure 15-21 Starting a server This automatically performs the following steps for you:  Publishes the enterprise application, if necessary  Publishes the server configuration, if necessary  Starts the server and the enterprise application Important: If you want to run the database applications using the remote WebSphere server, then you must implement the EJBBANK database on the remote server machine. See “Installing the EJBBANK database” on page 811 for instructions to set up the database. 536 WebSphere Studio Application Developer Version 5 Programming Guide A progress window displays the publishing of the applications to the WebSphere server (Figure 15-22). Figure 15-22 Application publishing progress window You will see the output from the remote server stdout log file in the Console window (lower right part of Figure 15-23). When the Console window shows the application is started, you can start a Web browser by clicking the icon in the toolbar. This brings up the Web browser and you can enter the URL for the applications. You can run most of the applications we developed without any changes, for example: http://vertex:9080/ItsoProGuideBasicWeb/ http://vertex:9080/ItsoProGuideStrutsWeb/ http://vertex:9080/ItsoProGuideWebServClient/sample/Banking/TestClient.jsp http://vertex:9080/ItsoProGuideWebServClient/TestBankingWebService.jsp When running the Struts Web application, your Application Developer window should look like Figure 15-23. Tip: If you select a project or an HTML/JSP file and Run on Server , the enterprise application is published again to the server. This can be time consuming for larger applications. It is faster to start a browser and enter the URL. You can also use an external browser instead of the internal browser of Application Developer. Chapter 15. Servers and server configurations 537 Figure 15-23 Running the application Using the Control option in the server’s context menu in the Server Configuration view or the context menu of the server in the Servers view are the best ways for controlling servers. Notes:  If you start the remote WebSphere Application Server instance before you start the IBM Agent Controller, you will receive an error message. Make sure the IBM Agent Controller is started first so it can keep track of the state of the WebSphere Application Server instance.  Do not stop the IBM Agent Controller when it is in control of a server. Doing so may cause it to lose track of the state of the server, and you may have to manually terminate the server process in the remote machine using the Windows Task Manager. 538 WebSphere Studio Application Developer Version 5 Programming Guide Although rare, it can happen that a server goes into an inconsistent state and you cannot start or stop it using its context menu. In that case you can add the Debug view by selecting Window -> Show view -> Debug and, by using the context menu of the server in the Debug view, you can terminate the server process and also remove terminated server processes, as shown in Figure 15-24. Figure 15-24 Terminating a server process Changing the applications to run on a remote server Some of our applications require changes to make them work on a remote server: ItsoProGuideDatabaseWeb The TestDBBeans.jsp requires a user ID and password for the remote server: <% Connect.setDriverName("COM.ibm.db2.jdbc.app.DB2Driver"); Connect.setUrl("jdbc:db2:EJBBANK"); Connect.setUsername("db2admin"); // authoized user ID Connect.setPassword("xxxxxxxx"); // authorized password SelectStatement.setConnectionSpec(Connect); SelectStatement.setCommand("SELECT * FROM ITSO.CUSTOMER"); SelectStatement.execute(); out.println("Row count is: " + SelectStatement.getRowCount()); %> Chapter 15. Servers and server configurations 539 The database Web pages application also requires user ID and password in the initialization parameters of the JSPs. Open the Web application deployment descriptor (web.xml) on the Servlets page (Figure 15-25): Figure 15-25  Select the ListCreditsMasterview and add values for username and password.  Do the same for the ListCreditsDetailsView. ItsoProGuideStoredProcWeb To run the stored procedures you have to redefine the stored procedures in the remote server DB2 system. You can use the DB2 net JDBC driver to connect to the database on the remote server and import the table definitions. Then you would have to recreate and build the stored procedures for the remote DB2 server. Apache Tomcat Application Developer 5.0 ships with support for Apache Tomcat 3.2, 4.0 and 4.1. However, it does not ship with the Apache Tomcat product itself. To use Apache Tomcat, you must therefore first download and install it on the machine running Application Developer. Tomcat can be downloaded from: http://jakarta.apache.org/tomcat/ Note: Building DB2 stored procedures using the net driver is very unstable. One solution is to define the remote database locally and use the app driver. Another solution is to build the procedures on the remote system. xxxxxxxx 540 WebSphere Studio Application Developer Version 5 Programming Guide When Tomcat has downloaded and installed, go to Window -> Preferences -> Server -> Apache Tomcat and fill in the information about where it is installed (Figure 15-26). Figure 15-26 Apache Tomcat preferences Once this is done, you can create a server and a server configuration as described in “Creating a server and server configuration together” on page 530, and select the appropriate version of Tomcat as the server type. TCP/IP Monitor The TCP/IP Monitor is a simple server that monitors all the requests and the responses between a Web browser and an application server. By default, when the TCP/IP Monitor is started, it listens for requests on port 9081 and then it forwards these requests to the application server on port 9080. For responses from the application server, the TCP/IP Monitor forwards them back. Note: Apache Tomcat can only be run as a built-in and local server, not as a remote server. Chapter 15. Servers and server configurations 541 Configuring the TCP/IP Monitor To set up the TCP/IP Monitor, perform these steps:  Switch to the Server perspective and select File -> New -> Server and Server Configuration .  Enter a name for the server (ItsoMonitor), select a folder to place it in (ItsoProGuideServer), select TCP/IP Monitoring Server as the server type, make sure that None is selected in the template drop-down list, and click Next (Figure 15-27). Figure 15-27 Creating a TCP/IP Monitoring Server This creates a monitoring server that listens to port 9080, which is the default for a WebSphere v5.0 test environment. If you would like to monitor a WebSphere v4.0 test environment, select Monitor on port 8080 as the template instead. 542 WebSphere Studio Application Developer Version 5 Programming Guide  On the next page you can configure on which host the server to be monitored is running. In our example we monitor a built-in test environment, so we use localhost as the hostname. Keep the port as the default 9080. Click Next . This creates the TCP/IP Monitoring Server and it is added to the list of servers in the Server Configuration view. Using the TCP/IP Monitor  To use the TCP/IP Monitoring Server it is best to start the monitor first. The Console view displays a message about the port the TCP/IP Monitoring Server is listening on: Monitoring server started localhost:9081 -> localhost:9080  Now start the ItsoServer server; we use the built-in server for this test. The console output of the monitor is replaced with the server console.  Bring up a Web browser and open the address: http://localhost:9081/ItsoProGuideStrutsWeb  The TCP/IP Monitor view is opened (Figure 15-28). Exercise the application by navigating through the pages to create some traffic. Figure 15-28 TCP/IP Monitor view Chapter 15. Servers and server configurations 543 The TCP/IP Monitor view lists all the HTTP requests that are generated and, if one is selected, the time, response time, and the type of request.  The TCP/IP Monitor can also show more detailed information about the traffic. Maximize the TCP/IP Monitor view by double-clicking its title or pressing Ctrl-M. This brings up the window shown in Figure 15-29. Figure 15-29 TCP/IP Monitor view - maximized By selecting an HTTP request in the top pane, you can see both the request from the browser and the response returned by the HTTP server. Tip: You can use the TCP/IP Monitor to watch HTTP traffic as well as Web services traffic. By default the generated proxy classes route the SOAP requests to port 9080, but you can easily change that port to 9081 and watch the SOAP messages in the TCP/IP Monitor. You can either change the Java code of the proxy or dynamically change the target address using the getEndpoint and setEndpoint methods. . database. 53 6 WebSphere Studio Application Developer Version 5 Programming Guide A progress window displays the publishing of the applications to the WebSphere server (Figure 15- 22). Figure 15- 22 Application. 53 4 WebSphere Studio Application Developer Version 5 Programming Guide Figure 15- 19 Defining an authentication entry On the Data source. process in the remote machine using the Windows Task Manager. 53 8 WebSphere Studio Application Developer Version 5 Programming Guide Although rare, it can happen that a server goes into an inconsistent

Ngày đăng: 03/07/2014, 20:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan