Installing and Configuring Struts


Installing and Configuring Struts

Although all Struts binaries required by the sample GreaterCause application are made available with the GreaterCause download, you can refer to http://jakarta.apache.org/struts/userGuide/installation.html to find out more about Struts installation and configuration. The binaries provided with the GreaterCause download pertain to Struts 1.1 beta release 2, which was used to test the application.

If you want to install the most current binaries, you will need the following from the Struts binary distribution for testing the sample GreaterCause application:

  • lib/commons-*.jar These JAR files contain packages from the Jakarta Commons project that are used by the Struts framework. Copy these files into the WEB-INF/lib directory of the GreaterCause application.

  • lib/struts.jar This JAR file contains all classes used by the framework. Copy these files into the WEB-INF/lib directory of the GreaterCause application.

  • lib/struts-*.tld Copy these tag library descriptor files into the WEB-INF directory of your web application.

Chapters 4 and 5 explain the deployment descriptor (web.xml) configured for using the Struts controller servlet. The following Struts-related tag library declarations are included in the web.xml deployment descriptor:

<taglib>
   <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
   <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
   <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
   <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
   <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
   <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
 

These tag libraries are referenced in the GreaterCause JSPs using the following declarations:

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
 

For modifying the characteristics of GreaterCause application, follow the instructions provided in Chapter 4 and 5 for creating/modifying entries in the WEB-INF/struts-config.xml file.

When compiling request handlers, form beans, or any other class that makes use of Struts components, include the struts.jar and commons-*.jar files in the CLASSPATH.

Configuring the Struts Validator

The sample application makes use of the Validator plug-in. The Validator services are injected into the Struts framework using the following declaration in the struts-config.xml file:

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
   <set-property property="pathnames"
      value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
 

The following two files are configured in the GreaterCause web application's WEB-INF directory:

  • Validator-rules.xml This file contains the basic validators that are packaged with the framework.

  • Validation.xml In this configuration file, we specify the validations associated with the form bean properties.

A detailed discussion of Validator is available at http://home.earthlink.net/~dwinterfeldt/overview.html.



Configuring the WebLogic Domain

Installing the WebLogic server is very simple and intuitive. You can download the WebLogic Platform 7.0 http://commerce.bea.com/index.jsp. Detailed instructions for installing the WebLogic Server 7.0 are available at http://edocs.bea.com/wls/docs70/install/index.html. For quick installation steps, please read on. For detailed information on configuring and using BEA WebLogic Platform 7.0, please refer to documentation available at http://edocs.bea.com/platform/docs70/index.html.

The following are fast-track instructions for creating a development environment:

  1. During the product download, BEA Installer will be launched. After you accept the BEA license agreement, provide the BEA home directory.

  2. For Install Type, choose Custom Installation.

  3. When on the Choose Components screen, at the minimum, choose WebLogic Server. This will also install the WebLogic Workshop IDE that will be used for developing Web services. The installer is now configured to download the required archives to continue installation.

  4. Specify the download directory and continue with the download.

  5. After the download is completed, you will be prompted to provide a product installation directory. If your home directory was c:\bea, the default product directory will be c:\bea\ weblogic700. Provide a suitable directory name and continue with the product install.

  6. Completion of product install will launch a configuration wizard. Select Yes to run the Domain Configuration Wizard. The wizard is used to set up WebLogic domains. The WebLogic installation provides a preconfigured WLS Examples domain (for running the Examples Server). You may choose the Examples Server to deploy the GreaterCause application, or you can configure a separate domain.

    Note 

    A domain is an interrelated set of WebLogic Server resources that are managed as a unit. A domain includes one or more WebLogic servers and may also include WebLogic Server clusters. Detail information on domains is available at http://edocs.bea.com/wls/docs70/admin_domain/index.html.

  7. Select WLS Domain from the template list to create a WebLogic Server domain, or select WebLogic Workshop for creating a Workshop domain that is used in Chapter 8 for creating Web services. Creating a WebLogic Workshop domain is recommended because it can be used for developing and testing the GreaterCause application, as well as the Web service. Name the domain appropriately. The discussions to follow will refer to the domain name as mydomain.

  8. When prompted to choose Server Type, select Single Server. This configuration is suitable and adequate for development and testing. In this case, the domain contains a single WebLogic Server instance that acts as both the Administration Server and application host server.

  9. When prompted for domain location, you can leave the default (for example, c:\bea\ user_projects\).

  10. On the Configure Standalone / Administrative Server screen, provide the server name (default is myserver). Leaving the Server Listen Address blank will assume localhost. You may choose to leave the port setting as is. Review the section Listen Address Considerations in the document Creating and Configuring WebLogic Server Domains at http://edocs.bea.com/wls/docs70/admin_domain/index.html for further information on Server Listen Address.

  11. On the Create Administrative User screen, provide the User Name and Password. This username and password will be required to start and manage the server. The default security realm myrealm will contain this user. Accidental removal of this user from the security realm will create an unusable domain.

  12. When prompted to Create Start Menu Entry, provide a suitable selection.

  13. Finally, review the Configuration Summary and create the new domain.

  14. If a single domain is sufficient for your needs, select End Configuration Wizard. If at a later time you choose to create more domains, run the Domain Configuration Wizard from the Start menu.

The downloaded GreaterCause package has a GC.properties file that is referenced by the Ant build script. You must update the WL_DOMAIN property in the GC.properties file to reflect the location of the domain directory. For example, you may specify this property, along with the WL_HOME property (WebLogic home directory), as shown here:

WL_HOME=C:\bea\weblogic700
WL_DOMAIN=C:\bea\user_projects\mydomain
 
Note 

After WebLogic server is installed, you can start the server either from the Windows Start menu or using the startWeblogic.cmd script provided in the ${WL_DOMAIN} directory. For testing the Web Service, ensure that the domain name refers to a Workshop domain.

Configuring the JDBC Connection Pool

For development and testing, we used an Oracle database server. In this section, we discuss the procedure for setting up a JDBC connection pool for the Oracle database server. We must first start the WebLogic server according to the instructions provided in the preceding section. The rest of the instructions are as follows:

Start the console using http://localhost:7001/console.

  1. Select mydomain | Services | JDBC | Connection Pools in the left-hand frame.

  2. Select the Configure A New JDBC Connection Pool link in the right-hand frame.

  3. Provide the following information and select <Create> to complete:

    Form Field

    Value


    Name

    GCPool


    URL

    jdbc:oracle:thin:@myhostname:1521:mySID, where SID is the service identifier


    Driver Classname

    oracle.jdbc.driver.OracleDriver


    Properties

    user=username


    Password

    password

  1. We must now assign GCPool to a target server. Select the Targets tab on the same page that was used in the previous step. Select the Servers tab. Select myserver and move it to the Chosen window. Apply the changes before exiting.

  2. Once the connection pool is created, we proceed to creating a JDBC Tx Data Source. Select mydomain | Services | JDBC | Tx Data Sources.

  3. Select Configure A New JDBC Tx Data Source link in the right-hand frame.

  4. Provide the following information and select <Create> to complete. The JNDI name provided here is the JNDI name referred to in the deployment descriptor of the entity beans. The two names should match for successfully deploying the application.

    Form Field

    Value


    Name

    GCTxDataSource


    JNDI Name

    jdbc/gcOracleTxPool


    Pool Name

    GCPool

  5. We must now assign GCTxDataSource to a target server. Select the Targets tab on the same page that was used in the preceding step. Select the Servers tab. Select myserver and move it to the Chosen window. Apply the changes before exiting.