Sie sind auf Seite 1von 55

L01: Using the WebSphere Application Server Liberty Profile for lightweight, rapid development

Lab Exercise

Copyright IBM Corporation, 2012 US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

IBM Software

Contents
LAB 1 USING THE LIBERTY PROFILE FOR LIGHTWEIGHT, RAPID DEVELOPMENT ............................................ 7 1.1 CONFIGURING YOUR DEVELOPMENT ENVIRONMENT (DISCONNECTED SCENARIO) ............................................ 9 1.1.1 INSTALL THE LIBERTY PROFILE IN A DISCONNECTED MODE ............................................................. 9 1.1.2 LAUNCH THE ECLIPSE INDIGO DEVELOPMENT ENVIRONMENT ....................................................... 13 1.1.3 CONFIGURE YOUR LIBERTY SERVER IN ECLIPSE IN A DISCONNECTED MODE ................................... 16 1.2 DEPLOYING A SAMPLE APPLICATION TO THE LIBERTY PROFILE .................................................................... 31 1.2.1 IMPORT A SAMPLE APPLICATION INTO ECLIPSE ............................................................................ 31 1.2.2 MODIFY THE APPLICATION ........................................................................................................ 35 1.2.3 MODIFY THE SERVER HTTP(S) PORTS ....................................................................................... 39 1.2.4 ADD INFO LOGGING OUTPUT TO THE CONSOLE .......................................................................... 45 1.2.5 UPDATE TRACE SPECIFICATION ................................................................................................ 47 1.3 CUSTOMIZING THE LIBERTY JVM OPTIONS ............................................................................................... 50 1.4 INTRODUCING THE LIBERTY ENVIRONMENT VARIABLE CONFIGURATION ........................................................ 52 1.5 INTRODUCING THE LIBERTY BOOTSTRAP PROPERTIES ............................................................................... 54 1.6 SUMMARY ............................................................................................................................................. 54 1.7 APPENDIX A: DOWNLOADING THE LIBERTY PROFILE FROM W ASDEV ........................................................... 55 1.8 APPENDIX B: DOWNLOADING ECLIPSE FROM W ASDEV .............................................................................. 57

Contents

Page 3

IBM Software

Lab 1

Using the Liberty Profile for lightweight, rapid development

In this lab, you are going to install the Liberty Profile in a disconnected mode, meaning the resources have already been downloaded from the internet and are available locally on the virtual image that has been provided. And, then use you will work with the Liberty profile server in Eclipse to do some simple application development. The Liberty Profile is a lightweight, composable application server runtime that is small to download, easy to install and configure, and very fast to start. Both the Liberty Profile and the Eclipse adapter to use this profile in your development environment are available at no charge for a single user to unit test your applications on the desktop.You can use this environment to develop applications against the lightweight Liberty Profile and then transfer your environment to a production Network Deployment server with full fidelity. This lab uses a desktop virtual image, and the following components have been previously downloaded from the internet and are available on the virtual image: __1. __2. __3. Eclipse 3.7.2 - Installed WebSphere Tools Plug-in for eclipse Liberty Profile server

The Eclipse Java EE IDE for Web Developers version 3.7.2 (Indigo) platform has been pre-installed on the virtual image. However, it is available as a free download on WASDev at the following URL: http://wasdev.net

The IBM JDK 1.6 has been pre-installed on the virtual image, and is set as the default JRE for the development environment.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 7

IBM Software

Windows NOTE: You may be prompted with a Windows security alert when launching the Liberty Server and deploying an application the server. Just select Unblock, and continue with the lab instructions.

In this exercise, you will:

Page 8

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

Install the WebSphere Application Server V8.5 Liberty Profile in a disconnected mode Install the WebSphere tools plug-in for Eclipse in a disconnected mode Configure Eclipse to work with your Liberty Profile server Use the Eclipse workbench to modify your Liberty Profile server configuration Use the Eclipse workbench to publish and modify an existing application Customize the Liberty Server JVM Options Be introduced to the Liberty Server Bootstrap properties file Be introduced to the Liberty Server environment configuration file

To run this lab, your workstation must meet the following requirements: Approximately 8GB of storage available for the Windows XP virtual image Approximately 1.5 GB of memory free to run the developer workbench and the server The lab files for this lab must be unzipped on your workstation; the instructions will refer to the location of the sample files using the <LAB_FILES> variable. Connectivity to the internet is NOT required

1.1

Configuring your development environment (Disconnected Scenario)

The Liberty Profile, Eclipse, and the WebSphere Developer Tools to support the Liberty Profile in Eclipse are all available as no-charge downloads for development and evaluation without IBM support. This means that you can set up an end-to-end development environment at no cost!

1.1.1
__1.

Install the Liberty Profile in a disconnected mode


Install the WebSphere Liberty profile from the package that has already been downloaded from the internet __a. Locate the <WLP_JAR> file that has been provided by the instructor. __i. Optionally, copy the LabFiles directory provided by the instructor to the C:\Student directory on the virtual image.

X:\Student\LabFiles\Lab01\LibertyProfile\wlp-developers-8.5.0.0.jar __b. Open a Windows command prompt. And, then change to the directory that contains the wlp-developers-8.5.0.0.jar file.
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 9

IBM Software

__c.

Run the following command to install the Liberty profile into C:\Student\LibertyWork directory: java -jar wlp-developers-8.5.0.0.jar --acceptLicense "C:\Student\LibertyWork"

__d. __e.

You will be left with a folder called C:\Student\LibertyWork\wlp (this document will refer to this folder as <LIBERTY_ROOT>). Thats it! The Liberty Profile is installed and ready to use!

TIP: Alternatively, the Liberty package can be downloaded and installed from the internet. The basic steps are illustrated in Appendix A. __f. __g. Explore the content of <LIBERTY_ROOT>. This should be located at C:\student\LibertyWork\wlp Open a file system browser or terminal session and go look at the content of the <LIBERTY_ROOT> folder.

__h.

Use a text editor to open the README.TXT file. It explains how to install and start the server, and contains information about how to configure the server, install applications, and so forth. You can close the text file, or keep it open as a reference.

Page 10

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__i.

A default server is NOT included in the Liberty package. In this step, you will create a new default server. __i. Open a Windows command prompt. And, then change to the <LIBERTY_ROOT>\bin directory. This directory contains the server command that can be used to create, stop, and start the Liberty server. It can also be used to dump the configuration to aid in customer support. Enter and execute the following command to create a new server named defaultServer. server create defaultServer

__ii.

__j.

Using the Windows Explorer, Look under <LIBERTY_ROOT>/usr/servers/defaultServer. The folder name defaultServer indicates the server name. Initially, the server contains a server.xml file with the JSP feature enabled, and default HTTP(S) endpoints configured. You can open the server.xml file in a text editor and view it: server.xml

__a.

In this exercise, you will not be modifying the server configuration files directly rather, you will set up your server configuration in the next sections, using Eclipse.
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 11

IBM Software

__b.

Notice that the server.xml file has the featureManager section with the jsp-2.2 feature enabled on this server. To see which feature options are available for the Liberty Profile, open the <LIBERTY_ROOT>/lib/features folder and look through the list of .mf files. These files represent all of the features that you can enable in your Liberty Profile server. __i. In terms of feature names, the string you need to include in the server.xml file to enable a feature corresponds to the name portion of the features .mf file. Consider the file jsp-2.2.mf. The feature name that you would add to the server.xml is jsp-2.2. For example: <feature>jsp-2.2</feature> Of course, you can add features to the server.xml file using the Liberty tooling in eclipse, as shown below. But dont worry; we will work with the Liberty Tools later in the lab.

__2.

Start the server. __a. __b. Open a command prompt or terminal session and navigate to <LIBERTY_ROOT>/bin Use the run option to start your server so that you can see the timestamp messages; you will not specify a server name, so the default server will be used. __i. __ii. __c. On Windows: server.bat run On other platforms: ./server run

The server will start very quickly; this sample output shows the server is ready to run. You should have noticed that the server started in just a few seconds.

Page 12

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__d. __e.

You will not be doing anything with the server now, so type CTRL+C in your command prompt to kill the server process. When prompted to terminate the batch job, type Yes.

1.1.2
__1.

Launch the Eclipse Indigo Development Environment


Launch the Eclipse Indigo for Java EE Developers (3.7.2) that has already been installed in the virtual image.

TIP: the first time you launch the eclipse development environment, you may be presented with a dialog to upload Data usage. Just click the Cancel button and continue with the lab.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 13

IBM Software

The Eclipse Indigo development environment is available as a free download, as a compressed archive file, from http://wasdev.net. The compressed archive is approximately 215 MB. __a. Using the Windows Explorer, navigate to the eclipse directory, C:\Student\LibertyWork\eclipse. The eclipse directory will be referred to in these instructions as <ECLIPSE_ROOT>. Inside of <ECLIPSE_ROOT>, locate the Eclipse application file and open it (for example, by double-clicking it in your file browser).

__b.

__c.

When the Eclipse launcher prompts you to Select a workspace, ensure the workspace is set to C:\Student\LibertyWork\workspace. And then click OK.

Page 14

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__e. Your Eclipse IDE will open to the Welcome page. Click the Workbench icon in the upper right to continue to your workbench and begin using Eclipse.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 15

IBM Software

TIP: As mentioned before, the Eclipse Indigo for Java EE Developers (3.7.2) can be downloaded from the internet. The basic steps are illustrated in Appendix B.

1.1.3
__1.

Configure your Liberty server in Eclipse in a disconnected mode


Install the WebSphere Liberty Profile developer tools plug-in for Eclipse from a previously downloaded zip file. __a. __b. IBM provides a no-charge adapter so that you can easily use your Eclipse environment with the Liberty Profile Start your Eclipse workbench if it is not already started. __i. __ii. __iii. __c. Navigate to <ECLIPSE_ROOT> (C:\student\LibertyWork\eclipse) Double-click on eclipse.exe Accept the default workspace location, when prompted

Within Eclipse, go to Help > Install New Software.

__d.

If there is no internet connection, you may see an error indicating a problem connecting to the software sites. That is OK since we will be installing from a local repository. Just click the OK button and continue.

Page 16

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__e.

On the Available Software page, click the Add button.

__f.

In the Add Repository Dialog, click on the Archive button and browse to the WebSphere Developer Tools zip archive file provided by the instructor. Then click the OK button to begin the installation of the plug-ins. X:\Student\LabFiles\Lab01\WebSphereDeveloperTools\wdt-update-site_8.5.0.WDT85I20120530_0920.zip

__g.

Install the Liberty Profile Server plug-in __i. From the list of available software to install, select the following components: (1) WebSphere Application Server V8.5 Tools Liberty Profile. (2) WebSphere Application Server V8.5 Tools __ii. __iii. Deselect the checkbox labeled Contact all update sites during install to find required software Click the Next button to install the selected components.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 17

IBM Software

NOTES: The Web Development Tools have been pre-installed on the virtual image. The WAS V8.5 Tools includes the WebSphere Persistence Editor which is needed in the lab.

__h.

Review the details of the items to be installed. And, then click the Next button.

Page 18

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__i.

Accept the license terms. And then click Finish to install the tools. Again, this process may take several minutes.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 19

IBM Software

__j.

Your Eclipse environment will begin processing the plug-in components; this process may take a few minutes.

__k.

If you are prompted with any security warnings, you can ignore the warning and click OK to continue the installation

Page 20

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__l.

When the installation finishes, you will be prompted to restart Eclipse. Click the Restart Now button. When Eclipse restarts, if you are prompted for a workspace, accept the default and click OK to continue to the development workbench.

__2.

Configure a Liberty server instance in Eclipse. __a. At the bottom of the IDE workbench, select the Servers tab, then right-click in the server list area and choose New > Server from the context menu.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 21

IBM Software

__b.

In the Define a New Server dialog, expand the IBM folder, and select WebSphere Application Server V8.5 Liberty Profile. Keep the default host and server names, and click Next.

Page 22

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__c.

In the WebSphere Runtime Environment dialog, click Browse to open the file system browser. Navigate to your <LIBERTY_ROOT> directory, C:\Student\LibertyWork\wlp. And, then click OK. TIP: The virtual image has the IBM JDK 6 installed, and we will use that for the Liberty server. Liberty can also run with the IBM JDK 7 and the Oracle Hotspot JDK 6 or 7. Notice that, if you do not have the Liberty profile installed yet, you can easily download and install it using the links on this panel. Click Next to continue.

__d.

In the WebSphere Server dialog, notice that the WebSphere server field is set to your defaultServer instance. __i. For this exercise, create a new instance for your development environment by clicking the New button.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 23

IBM Software

__e.

In the new server panel, locate the Server name field and type labServer. You will be using this server to run a simple servlet sample application. Click Finish.

__f.

In the New Server dialog, click Finish.


You will notice that the server contains the jsp-2.2 feature enabled and a default HTTP Endpoint definition.

Page 24

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__g.

Now your server is defined!

__3.

Start the server. __a. From the Servers view, select your labServer instance and click the Start the server button ( ). Alternatively, you can also right-click the server name and choose the Start option from the context menu. Switch to the Console view. Look at the messages to see how fast your server starts!
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

__b.

Page 25

IBM Software

__4.

Modify the lab server configuration. __a. __b. In the Servers view, double-click on your labServer server to open the configuration editor (or right-click and select Open from the context menu). First, expand the Publishing section and notice that the server is set to automatically detect and publish changes. Keep this default setting.

Page 26

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__c.

In this exercise, you will be deploying a simple servlet application, so try enabling the servlet feature on this server. On the Overview page, locate the Liberty Profile Settings section, and click the Open server configuration link to open the server.xml editor.

__d.

Start by providing a meaningful description for your server. In the Configuration Structure area, highlight the Server Configuration item in the list. In the Configuration Details area on the right, delete the default description for your server and provide something more meaningful, such as Liberty server for labs.

__e.

To add a feature, such as servlet-3.0, go back in the Configuration Structure area, and determine if the Feature Manager has already been added to the configuration. __i. __ii. The Feature Manager will already exist in the configuration if the Liberty Server configuration already has features defined, such as jsp-2.2. Review the Feature Manager settings. In this lab, the Feature Manager has already been added to the configuration profile because of the jsp-2.2 feature having been included in the labServer you created earlier.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 27

IBM Software

__f.

Add an additional feature (servlet-3.0) __i. Select Feature Manager located under the Configuration Structure area.

__g.

Highlight Feature Manager in the Server Configuration list. On the right side, in the Feature Manager Details area, click the Add button. Then, use the menu to select the servlet-3.0 feature.

__h.

In the server.xml editor, switch to the Source tab at the bottom to see the XML source for this configuration file. You will see that a new featureManager element has been added, and that it contains the servlet-3.0 feature.

Page 28

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__i.

Now you have a server that is configured to use the servlet-3.0 feature. Click the Save button ( ) to save your changes (or use CTRL+S).

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 29

IBM Software

__j.

Switch to the Console panel at the bottom of the workbench and review the latest messages. These messages are showing that your Liberty server automatically detected the configuration update, processed the feature that you enabled, and is now listening for incoming requests. __i. You will notice that the server configuration was automatically updated and the feature update was completed very quickly. In this example, it was one second.

__k.

Now you are ready to start working with a sample application that uses the Servlet or JSP features.

Page 30

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

1.2
1.2.1
__1.

Deploying a sample application to the Liberty Profile


Import a sample application into Eclipse
A simple servlet WAR file has been provided for this exercise; import it into your workbench. __a. In Eclipse, go to File > Import. Expand the Web section, then select WAR file. Click Next.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 31

IBM Software

__b. __c.

In the WAR file field, select Browse. Navigate to X:\Student\LabFiles\Lab01\Sample1.war and click Open. Set the Target runtime to WebSphere Application Server V8.5 Liberty Profile. Click Finish

__d.

Now, you have a Sample1 web project in your workspace. You can expand it in the Enterprise Explorer view to see the different components of the project.

Page 32

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__2.

Start the sample application. __a. In the Enterprise Explorer pane, navigate to the SimpleServlet.java as shown below. __i. __b. __c. Sample1 -> Java resources -> src -> wasdev.sample -> SimpleServlet.java

Right-click on SimpleServlet.java. From the context menu, select Run As > Run on Server.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 33

IBM Software

__d.

In the Run On Server dialog, verify that Choose an existing server is chosen. __i. Under localhost, select the WebSphere Application Server V8.5 Liberty Profile server that you defined earlier. The server should be listed in Started state. __ii. Click Finish.

__e.

After a moment, your application will be installed and started. See the Console pane for the corresponding messages.

Page 34

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__f. __g. __h.

In the main panel of the workbench, a browser also opened, pointing to http://localhost:9080/Sample1/SimpleServlet. If you receive a 404 the first time, try to refresh the browser once the application is completely deployed and started. At this point, you should see the rendered HTML content generated by the simple servlet.

1.2.2
__1.

Modify the application


Open the servlet source. __a. In the Enterprise Explorer panel, expand the Sample1 project, then go to Sample1 > Servlets. Double-click the wasdev.sample.SimpleServlet entry to open the Java editor for the servlet.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 35

IBM Software

Page 36

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__b.

This is how the SimpleServlet.java source looks in the editor:

__c.

This is a very simple servlet with a doGet() method that sends out an HTML snippet string as a response. Your doGet() method will look similar to this (some of the HTML tags might be a little different that is ok).

/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().print( "<h1><font color=green>Simple Servlet ran successfully</font></h1>" + "Powered by WebSphere Application Server V8.5 Liberty Profile"); }

__2.

Modify the application and publish the change. __a. In the doGet() method, Locate the <h1> heading element of the HTML string, and notice that it contains a font tag to set the color to green. Modify this string by changing the text green to purple, so your font tag will look read <font color=purple>.

response.getWriter().print( "<h1><font color=purple>Simple Servlet ran successfully</font></h1>" + "Powered by WebSphere Application Server V8.5 Liberty Profile");
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 37

IBM Software

__b. __c.

Save your changes to the Java source file by either clicking the Save button ( CTRL+S.

) or using

Recall that your server configuration is setup to automatically detect and publish application changes immediately. By saving the changes to your Java source file, you automatically triggered an application update on the server. To see this, go to the Console view at the bottom of the workbench. The application update started almost immediately after you saved the change to the application, and the update completed in seconds.

__d.

__3.

Access the updated application. __a. Refresh the browser in your workbench to see the application change. The title should now be rendered in purple text.

__b.

Optionally continue to play around with application modifications and see how quickly those changes are available in the deployed application. Maybe put in some additional text to display on the page, or add extra HTML tags to see formatting changes (you could add a title tag to set the text displayed in the browser title bar, for example, <head><title>Liberty Profile</title></head>). The key is that this edit / publish / debug cycle is very simple and fast!

__c.

Page 38

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

1.2.3
__1.

Modify the server HTTP(s) ports


Open the server configuration editor. __a. In the Servers view, double-click on the labServer server to open the configuration Overview page (or right-click the labServer server and choose Open).

__b.

In the Liberty Profile Settings section, select the Open server configuration link to open the server.xml editor.

__c.

Ensure you are in the Design mode by selecting the Design tab on the Server Configuration editor.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 39

IBM Software

__d.

Under the Configuration Structure section, Click on Feature Manager.

__e.

Select the Application: Sample1 item in the Server Configuration and look at its configuration details. From here, you can set basic application parameters, including the context root for the application.

Page 40

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__f.

Select the Application Monitoring item in the Server Configuration and look at its configuration details. You can see that the monitor polls for changes every 500ms using an mbean trigger. You did not add any JMX features to your server to support mbean notification so how is that working?

__g.

Select the Feature Manager item to see the features that are configured on your server. You added the servlet-3.0 feature because you knew that you were going to be running a servlet application. But the development tools automatically added the localConnector-1.0. feature to your server to support notifications and application updates. In fact, you would not have needed to add the servlet feature to your server at the beginning at all the tools would have automatically enabled that feature, based on the content of the application.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 41

IBM Software

__2.

Change the HTTP port. __a. __b. Using the default HTTP port (9080) is an easy way to quickly bring up an application, but it is common to want to use a different port. This is an easy thing to change. In the Configuration Structure area, select Server Configuration, then select HTTP Endpoint

Page 42

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__c.

In the HTTP Endpoint Details area, Change the HTTP Port to 9580. __i. Update the Port field to 9580.

__d. __e.

Save your changes to the server configuration (CTRL+S). You can review your full server configuration in the server.xml source file. Back in the server configuration editor, switch to the Source tab at the bottom to view the full XML source for your server configuration.

__f.

After you saved your configuration changes, the configuration of your running server was automatically updated. The Console pane will show that the Sample1 servlet is now available on port 9580.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 43

IBM Software

__g.

Now, you can access your sample application using the new port. In the browser in your workbench, change the port from 9080 to 9580 and refresh the application.

Page 44

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

1.2.4

Add INFO logging output to the Console

By default, the Liberty profile Server has the console log level set to AUDIT. In this section, you will change the level of log messages written to the console from AUDIT to INFO. You will perform this activity in the server.xml file using the UI. It is also possible to set default logging options in the bootstrap.properties file. If the logging options are set in the bootstrap.properties file, the logging options will take effect for ALL servers that are defined. __1. Open the server configuration editor. __a. __b. In the Servers view, double-click on the labServer server to open the configuration Overview page (or right-click the labServer server and choose Open). In the Liberty Profile Settings section, select the Open server configuration link to open the server.xml editor.

__c. __2.

Ensure you are in the Design mode by selecting the Design tab on the Server Configuration editor.

Add the Logging configuration option to the server __a. Under the Configuration Structure section, Click on Server Configuration. And, then click the Add button.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 45

IBM Software

__b.

On the Add Item dialog, select Logging, And, then click the OK button.

__c. The logging page displays the properties for the logging configuration, such as the name of the log files, the maximum size of log files, and the maximum number of log files to retain. Additional configuration information is displayed regarding tracing. Notice that the Console Log Level is set to AUDIT by default.

Page 46

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__3.

Change the Console log level to INFO using the pull down menu.

__a. Switch to the Source view for the server.xml file to see the configuration changes added to server.xml. <logging consoleLogLevel="INFO"/> __b. __c.

Save the configuration file. Stop and restart the server. The changes you made are dynamic and take effect immediately. However, running the SimpleServlet does not produce INFO messages because the Servlet has already been initialized in the environment. When you restart the server, you will immediately see INFO messages in the console.

1.2.5

Update Trace Specification

By default, the Liberty profile Server trace specification is set to *=info=enabled. This is the same for Traditional WAS. Updating the trace specification for debugging is easily performed using the server configuration editor. You can specify the trace specification in the UI, or copy / paste the trace specification directly into the server.xml file. In this section, you will specify a trace specification using the configuration editor. And, then, you will look at the result in the servr.xml source file __1. Open the server configuration editor, if it is not already opened.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 47

IBM Software

__a. __b.

In the Servers view, double-click on the labServer server to open the configuration Overview page (or right-click the labServer server and choose Open). In the Liberty Profile Settings section, select the Open server configuration link to open the server.xml editor.

__c. __2.

Ensure you are in the Design mode by selecting the Design tab on the Server Configuration editor.

Update the Trace Specification under the logging configuration. __a. Click on Logging under the Server Configuration section. This displays the logging and trace details.

__b.

Update the Trace Specification field with the following trace string:
webcontainer=all=enabled:*=info=enabled

__c.

Switch to the Source tab on the configuration editor and view the logging configuration. :
<logging traceSpecification="webcontainer=all=enabled:*=info=enabled"/>

Page 48

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__d. __3.

Save the configuration changes.

Run the SimpleServlet to produce trace messages. __a. __b. Navigate to SimpleServlet.java Using the menus, run the SimpleServlet on the Liberty Server

__4.

Verify that the trace.log file contains trace data. __a. From a Windows Explorer, navigate to the server logs directory. C:\Student\LibertyWork\wlp\usr\servers\labServer\logs The trace.log file has been created and contains content.

__b.

You can view the trace.log file using Notepad.


Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 49

IBM Software

Note: To open the trace.log file using Wordpad, you must first stop the Liberty server.

__5.

Very importantly, reset the trace specification back to the defualt value. __a. Switch to the Source tab on the configuration editor and update the logging configuration to:
logging consoleLogLevel="INFO" traceSpecification="*=info=enabled "/>

__b.

Save the configuration.

1.3

Customizing the Liberty JVM Options

The generic JVM arguments are used to configure and adjust how the JVM executes. The WebSphere Application Server Liberty profile is pre-configured with minimal settings defined. The following steps will direct you how to define custom generic JVM arguments such as heap settings for a Liberty server. __1. Create a text file named jvm.options in the ${server.config.dir} directory. TIP: On the virtual image for this lab, the ${server.config.dir} is c:\Student\LibertyWork\wlp\usr\<servers>\<serverName> The built in environment variables in the Liberty profile are discussed I the next section of this lab. __a. __b. __c. Open the Enterprise Explorer view in eclipse Navigate to WebSphere Application Server V8.5 Liberty profile Servers labServer. Right mouse click on the labServer folder. And, then select New File from the context menu.

Page 50

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

__d.

Create new file named jvm.options in the labServer folder

__2. __a.

Insert your generic JVM options, one per line, into the jvm.options file. Double click to open the file in the eclipse text editor

__b. Enter the following two lines in the jvm.options file to set the minimum and maximum heap size for eth labServer server. The following options will set the min / max JVM heap size to 25 MB and 500 MB respectively. -Xms25m -Xmx500m

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 51

IBM Software

TIP: The default minimum and maximum heap size values of the JVM heap size is: Xms4m and Xmx488m VerboseGC can be enabled by specifying -verbose:gc in the jvm.options file. Verbose GC output will be logged to the following location by default: <wlp.install.directory>/usr/servers/<serverName>/logs/console.log

TIP: Depending on your preferences, you might configure a single JVM or all Liberty JVMs with your options file. __a. To apply these settings to a single server, save jvm.options at: ${server.config.dir}/jvm.options TIP: On the virtual image for this lab, the ${server.config.dir} is c:\Student\LibertyWork\wlp\usr\<servers>\<serverName>

__b.

To apply these settings to all Liberty Servers, save jvm.options at: ${wlp.install.dir}/etc/jvm.options TIP: On the virtual image for this lab, the ${wlp.install.dir} is c:\Student\LibertyWork\wlp

The changes will take effect for all JVMs that do not have a locally defined jvm.options file. __3. Restart the server to enable changes.

This concludes the customization portion of the lab. In the next sections, you will be introduced to the Liberty configuration files for customizing the server initialization and environment settings.

1.4

Introducing the Liberty Environment Variable configuration

You can customize the Liberty profile environment using certain specific variables to support the placement of product binaries and shared resources.
Page 52
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

The Liberty environment variables are specified using server.env file. You can use server.env file at the installation and server levels to specify environment variables such as JAVA_HOME, WLP_USER_DIR and WLP_OUTPUT_DIR.

NOTE: You will not modify the default environment configuration in this lab. Review the information in this section to become familiar with the environment variables that are available for customizing the Liberty environment. The following Liberty profile specific variables can be used to customize the Liberty profile environment:

${wlp.install.dir} This configuration variable has an inferred location. The installation directory is always set to the parent of the directory containing the launch script or the parent of the /lib directory containing the target jar files. TIP: On the virtual image for this lab, the ${wlp.install.dir} is c:\Student\LibertyWork\wlp

WLP_USER_DIR This environment variable can be used to specify an alternate location for ${wlp.install.dir}. This variable can only be an absolute path. If this is specified, the runtime environment looks for shared resources and server definition in the specified directory. The ${server.config.dir} is equivalent to ${wlp.user.dir}/servers/serverName. TIP: On the virtual image for this lab, the ${server.config.dir} is c:\Student\LibertyWork\wlp\usr\<servers>\<serverName>

WLP_OUTPUT_DIR This environment variable can be used to specify an alternate location for server generated output such as logs, the workarea directory and generated files. This variable can only be an absolute path. If this environment variable is specified, ${server.output.dir} is set to the equivalent of WLP_OUTPUT_DIR/serverName. If not, the ${server.output.dir} is the same as ${server.config.dir} . TIP: On the virtual image for this lab, the ${server.output.dir} is c:\Student\LibertyWork\wlp\usr\<servers>\<serverName>, which is the same as ${server.config.dir}.
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 53

IBM Software

1.5

Introducing the Liberty Bootstrap Properties

In this section of the lab, you will gain an understanding of how and when bootstrap properties are required during environment initialization. NOTE: You will not modify any of the default environment initialization. This information is provided in the lab for your reference. Bootstrap properties are used to initialize the runtime environment for a particular server. Generally, they are attributes that affect the configuration and initialization of the runtime. Bootstrap properties are set in a text file named bootstrap.properties. This file should be located in the server directory alongside the configuration root file server.xml. By default, the server directory is usr/servers/server_name. The bootstrap.properties file contains two types of properties: A small, predefined set of initialization properties. Any custom properties you choose to define which you can then use as variables in other configuration files (that is, server.xml and included files). You can edit the bootstrap.properties file using a text editor, or using the editor that is part of the Liberty profile developer tools. Changes to the bootstrap.properties file are applied when the server is restarted. TIP: As an example, the logging service can be controlled through the server configuration (server.xml) file. Occasionally you need to set logging properties so they can take effect before the server configuration files are processed; In this case you set them in the bootstrap.properties file instead of the server configuration. You do not usually need to do this to get logging from your own code, which is loaded after server configuration processing, but you might need to do this to analyze problems in early server start or configuration processing.

This completes the lab exercise.

1.6

Summary

In this exercise, you: Installed the WebSphere Application Server V8.5 Liberty Profile
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 54

IBM Software

Installed the Liberty Profile tools plug-in Configured a Liberty Profile server in your Eclipse environment and modified the server configuration Deployed a sample application and experienced the rapid edit / deploy cycle that is supported by this environment Added additional server features Modified the HTTP Endpoint configuration Customized the JVM options for the lab server to setup the min / max heap sizes for the lab server. Familiarized yourself with the environment initialization, (bootstrap.properties) file. Familiarized yourself with the environment configuration options, (server.env) file for the Liberty profile.

1.7

Appendix A: Downloading the Liberty Profile from WasDev

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 55

IBM Software

The Liberty package can be downloaded and installed from the internet. For your reference, the basic steps are illustrated below. This is for your reference only. Do not download the resources from the internet in this lab. __a. __b. __c. Open a web browser and go to http://wasdev.net Go to the Download tab. In the main area at the top of the page, locate the Just want the Liberty Profile section, and click the button to download the Liberty Profile (the text here, shown below).

Page 56

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

IBM Software

1.8

Appendix B: Downloading Eclipse from WasDev

As mentioned before, the Eclipse Indigo for Java EE Developers (3.7.2) can be downloaded from the internet using these simple steps. This is for your reference only. Do not download the resources from the internet in this lab. __a. __b. In your browser, go back to http://wasdev.net and go to the Download section. From the main download area at the top of the page, locate Step 1, to download and install Eclipse. Click the link Eclipse Indigo for Java EE Developers (3.7.2). This will redirect you to the Eclipse download page.

__c.

The Eclipse package is approximately 200MB in size, and may take several minutes to download.

Discovering the value of IBM WebSphere Application Server V8.5 for Administrators An IBM Proof of Technology

Page 57

Das könnte Ihnen auch gefallen