Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Run J2EE Deployathon Online! With BEA WebLogic

 
 

Articles Index


Introduction

Deploying the Java Pet Store Application on WebLogic Server

Step 1: Download and Install Java 2 SDK, Standard Edition v1.2.2
Step 2: Download WebLogic Server version 5.1 and Latest Service Pack
Step 3: Install and Configure WebLogic Server and Service Pack
Step 4: Download the Java Pet Store Application
Step 5: Install and Configure the Java Pet Store Application
Step 6: Start WebLogic Server
Step 7: Run the Java Pet Store Application
Notes
Running Deployathon Online! With an Oracle Database

Step 1: Download and Install Java 2 SDK, Standard Edition v1.2.2

The Pet Store application has been tested with WebLogic Server (WLS) 5.1 running on JavaTM 2 SDK, Standard Edition v1.2.2. If Java 2, Standard Edition v1.2.2 is not already installed, you need to install it now. To download and install Java 2 SDK, Standard Edition v1.2.2, follow the instructions on the Java 2 SDK, Standard Edition v1.2.2 download page

.

Step 2: Download WebLogic Server version 5.1 and Latest Service Pack

Download the version of WLS 5.1 that is appropriate for your platform at the BEA WebLogic Server download page.

Download the most recent Service Pack (sp3 or greater) for WLS 5.1 at the WebLogic Server Service Packs download page.

Download Service Pack 3 for WLS 5.1 at the WebLogic Server Service Packs download page. Note: You must download Service Pack 3. Only Service Pack 3 has been certified to work with the Pet Store application.

Step 3: Install and Configure WebLogic Server and Service Pack

Install WebLogic Server by following the instructions at Installing and Setting Up WebLogic Server 5.1.

Install the Service Pack by following the instructions included with the Service Pack.

Step 4: Download the Java Pet Store Application

There are two parts to the Pet Store Application:

  • The Pet Store Application file from Sun Microsystems.
  • The SecurityAdapter implementation that is specific to WebLogic Server.

Pet Store Application

You can download the Java Pet Store Application from the Java 2 Platform, Enterprise Edition Download and Specification page. Go to the section "J2EETM Blueprints" and the subsection "Java Pet Store sample application." You can download the appliction in zip format, Solaris script format, or in an InstallShield executable for Windows NT.

To unzip the downloaded application in zip format:

  • Change your directory to the directory that contains the download, for example: cd /home/j2dep
  • Unzip the file: unzip jps1_0.zip

To extract the downloaded application in Solaris script format:

  • Change your directory to the directory that contains the download, for example: cd /home/j2dep
  • Make the downloaded file executable: chmod a+x jps1_0-solsparc.sh
  • Execute the downloaded file: ./jps1_0-solsparc.sh

To extract the downloaded application in InstallShield format, double-click on the executable and follow the instructions.

WLS SecurityAdpater Implementation

Download the WLS SecurityAdapter Implementation petStoreWL.jar. Extract the jar file into the root directory of your WLS 5.1 installation. This will create a petStore directory under the root directory of your WebLogic distribution. The petStore directory contains:

  • Classes for the SecurityAdapter implementation
  • Classes for an RDBMSRealm implementation
  • The database used to store the RDBMSRealm information and the Pet Store inventory/account information
  • Source files for the security implementation
  • Shell scripts used to configure and start the Pet Store application.

Step 5: Install and Configure the Java Pet Store Application

  • In the root directory of your WebLogic Server installation, edit the setEnv.cmd (for NT) or setEnv.sh (for UNIX) shell script so that the service pack jar file (weblogic510sp[version].jar) appears at the beginning of the CLASSPATH variable.
  • From the root directory of your WebLogic Server installation, set up your development environment by executing setEnv.cmd (for NT) or setEnv.sh (for UNIX).
  • Copy the estore.ear file from the Pet Store Application installation into the weblogic/petStore directory, where weblogic is the WebLogic Server installation directory.
  • Change the current directory to the weblogic/petStore directory and execute port2WL.cmd (for NT) or port2WL.sh (for UNIX). This unpacks the ear file, generates the EJB container classes, and includes the appropriate WebLogic-specific deployment descriptors.
  • Add the name of the SecurityAdapter implementation class to the deployment descriptors for the EJBs and Web Application by performing the following steps:
    • Edit weblogic/petStore/petStoreServer/estore/WEB-INF/web.xml so that the value of securityAdapterClassName is com.bea.estore.util.WLSecurityAdapter.
    • Change the current directory to the weblogic/petStore directory, and extract the ejb-jar.xml file from estoreEjb_WL.jar with the following command:
      jar xvf estoreEjb_WL.jar META-INF/ejb-jar.xml
    • Edit ejb-jar.xml so that the value of securityAdapterClassName is com.bea.estore.util.WLSecurityAdapter.
    • Change the current directory to the weblogic/petStore directory, and place ejb-jar.xml back into estoreWjb_WL.jar with the following command:
      jar uvf0 estoreEjb_WL.jar META-INF/ejb-jar.xml
  • Edit weblogic/petStore/petStoreServer/estore/WEB-INF/web.xml so that the values of the <form-login-page> and <form-error-page> tags are as follows:
    <form-login-page>/control/formbasedlogin
            </form-login-page>
    <form-error-page>/control/formbasedloginerror
    </form-error-page>
  • If you will not be connected to the internet while running the PetStore application or if you are connected to the internet through a proxy, you may not be able to resolve the reference to the Web Application 2.2 DTD contained in:
     weblogic/petStore/petStoreServer
                   /estore/WEB-INF/web.xml 
                   

    Since WebLogic Server contains a local copy of the Web Application 1.2 DTD you can edit:

    weblogic/petStore/petStoreServer
                     /estore/WEB-INF/web.xml
    

    so that the version of the DTD listed in the DOCTYPE declaration is 1.2 as shown below:

     <!DOCTYPE web-app PUBLIC '-
    //Sun Microsystems, Inc.//DTD Web Application1.2//EN'
    'http://java.sun.com/j2ee/dtds/web-app_2.2.dtd'>
    
  • Edit weblogic/petStore/petStoreServer/estore/WEB-INF/web.xml so that the value of the serverType variable is "WebLogic Server."
  • In the weblogic/petStore/weblogic.properties file:
    • Configure a system password by editing the weblogic.password.systemproperty, that is:
      weblogic.system=password
    • The weblogic/petStore/weblogic.properties file was created assuming that WebLogic was installed in the default location on a Windows NT machine. If you installed WebLogic in another location or platform, search the properties file for the string "c:/weblogic" and replace it with the appropriate directory.
    • Configure JSP pages with the following properties:
      weblogic.httpd.register.*.jsp=\
             weblogic.servlet.JSPServlet
      weblogic.httpd.initArgs.*.jsp=\
             pageCheckSeconds=1,\
             compileCommand=jdk_home/bin/javac.exe,\
             workingDir=\
             weblogic_home/petstore/classfiles,\
             verbose=true,\
             keepgenerated=true
      

      where jdk_home is the installation directory of your Java 2 SDK and weblogic_home is the installation directory of Weblogic Server.
  • Edit weblogic/petStore/startPetStore.cmd (for NT) or weblogic/petStore/startPetStore.sh (for UNIX) by adding the Service Pack jar file (weblogic510sp[version].jar to the PRE_CLASSPATH variable. You also need to add the Service Pack boot jar file (weblogic510sp[version]boot.jar) to the begining of the JAVA_CLASSPATH variable. Note that JAVA_CLASSPATH is set in multiple places in the script. You should add the boot jar file to each instance of JAVA_CLASSPATH.

Step 6: Start WebLogic Server

To start WebLogic Server, change the current directory to the weblogic/petStore directory, and execute startPetStore.cmd (for NT) or startPetStore.sh (for UNIX).

Step 7: Run the Java Pet Store Application

  • Open your Web browser.
  • Specify the URL: http://localhost:7001/estore/index.html

Notes

It might take a while for a page to appear for the first time after you deploy the pet store application or when a WebLogic Server is restarted. Please be patient. JSP pages are compiled to servlets on demand, so an initial access to a web page that invokes JSPs incurs some extra latency. Subsequent access to the web page should be faster.

Running Deployathon Online! With an Oracle Database

The Pet Store application is pre-configured to work with the evaluation version of Cloudscape that is included in the WebLogic Server distribution. If you would like to use Oracle with Pet Store, follow the steps below.

  • Create the database tables by executing weblogic/petStore/WLSrc/db/petStore.ddl with utils.Schema. First, edit petStore.ddl and make any changes required for your DBMS. Do not change the table or column names. See WebLogic Utilities for help using utils.Schema.
  • Edit the weblogic/rdbmsrealm.properties file.

    The rdbmsrealm.properties file contains two sections. In the first section, you set properties for your JDBC driver and the database where you created the RDBMSRealm tables. The Cloudscape JDBC driver is selected by default. If you want to use a different database, comment out the Cloudscape properties and uncomment the properties for the driver you want to use. Edit the properties so that they are correct for your database.

    • The driver property is the full classname of the JDBC driver, which must be in the WebLogic Server classpath.
    • The dbURL property is the database URL for the database, as specified by your JDBC driver documentation.
    • The dbUser property is the database username.
    • The dbPassword property is the password for the database user.
  • Edit the weblogic/petStore/weblogic.properties file. For the InventoryPool and EstorePool connection pools, edit the properties:
    • url - the database URL for the database, as specified by your JDBC driver documentation.
    • driver - the full
    • classname of the JDBC driver, which must be in the WebLogic Server classpath.

Back to Top
Introduction