Web Logic Deploy

Embed Size (px)

Citation preview

  • 7/28/2019 Web Logic Deploy

    1/7

    Deploying to a BEA WebLogic Server

    February 2006[Revision number: V2-1]Copyright 2006 Sun Microsystems, Inc.

    This tutorial takes you through the process of deploying an application that has been developed in the Java Studio Creator integrateddevelopment environment (the IDE) to a BEA WebLogic 8.1 server.

    Contents

    - Exporting the WAR File

    - Configuring the Classpath Settings

    - Configuring a JDBC Connection Pool

    - Configuring a JDBC Data Source

    - Using the Builder Tool to Modify the WAR File

    -Deploying the Application to the WebLogicServer

    To complete this tutorial, you need to have access to both the Java Studio Creator IDE and a BEA WebLogic server to which to deploy yourapplication. This tutorial was developed using BEA WebLogic Server version 8.1 SP4. You need to be familiar with the application server

    technology. You also need to have a domain configured with your Web Logic server before starting with this tutorial. If you are unfamiliarwith the BEA WebLogic Server, read its documentationbefore proceeding with this tutorial.

    You need to start with a web application that you developed using the Java Studio Creator IDE. Ensure that the application deployssuccessfully to the development container that is bundled with the IDE before you deploy your application to the WebLogic server. If yourapplication uses JDBC data sources, you need to include the classpaths for their corresponding database drivers in the BEA WebLogicdomain startup file, startWebLogic.cmd , (or startWebLogic.sh for UNIX platforms).

    The DataboundComponents_MySQL sample application used in this tutorial was developed in the IDE using the Using DataboundComponents to Access Databases tutorial but with a MySQL database.

    Exporting the WAR File

    Before you can deploy your application to a WebLogic Server, use the IDE to export a web application archive (WAR) file for your

    application. The WAR file contains the complete web application in compressed form.

    1. Open your project in the IDE.

    2. In the Projects window, right-click the project name and choose Export WAR file.

    3. In the Export WAR dialog box, choose the J2EE 1.3 specification.

    WebLogic Server 8.1 is compliant with J2EE 1.3.

    4. Enter the location to which to export the WAR file and click OK.

    Configuring the Classpath Settings

    The JavaServer Pages Standard Tag Library (jstl.jar) and the Apache Tag Libraries (standard.jar) are used by applicationsdeveloped with the Java Studio Creator IDE. You need to add these JAR files to the WebLogic server's classpath settings for the theapplication to deploy correctly.

    1. From http://apache.mirrors.pair.com/jakarta/taglibs/standard-1.0, download the jakarta-taglibs-standard-current.zip file. Extract the files into a directory of your choosing.

    2. After you extract the zip file, locate the following JAR files from the extracted lib subdirectory.

    r jstl.jar

    r standard.jar

    1

    http://e-docs.bea.com/wls/docs81/index.htmlhttp://e-docs.bea.com/wls/docs81/index.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/databoundcomponents.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/databoundcomponents.htmlhttp://apache.mirrors.pair.com/jakarta/taglibs/standard-1.0http://apache.mirrors.pair.com/jakarta/taglibs/standard-1.0http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/databoundcomponents.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/databoundcomponents.htmlhttp://e-docs.bea.com/wls/docs81/index.html
  • 7/28/2019 Web Logic Deploy

    2/7

    3. Edit the startWebLogic.cmd file (or startWebLogic.sh for UNIX platforms) for your WebLogic domain and add the

    following line immediately before the line where the CLASSPATH variable is first defined.

    set CLASSPATH=yourdir\lib\jstl.jar;yourdir\lib\standard.jar;%CLASSPATH%

    whereyour-diris the path to the directory where you downloaded the JAR files in the previous step.

    Note that for a default configuration of a BEA WebLogic Server domain on a Microsoft Windows XP system, the command file tostart the domain is located atBEAhome\user_projects\domains\domain_name\startWebLogic.cmd , whereBEA-home is where you installed the WebLogic server and domain-name is the name of the WebLogic domain you want to use. For UNIXand Linux platforms, the startup file is atBEAhome/user_projects/domains/domain_name/startWebLogic.sh

    4. Define the path to the database driver files needed to run your application, if necessary.

    For example, the DataboundComponents_MySQL application uses a MySQL database and the MySQL JAR file needed to run theapplication is added in the WebLogic domain startup file. The following lines are added immediately before the CLASSPATHvariable you defined in the previous step.

    set MYSQL_CLASSPATH=yourdir\mysql-connector-java-3.1.11-bin.jar

    set CLASSPATH=%MYSQL_CLASSPATH%;%CLASSPATH%

    The MySQL JAR file used above can be downloaded from the MySQL web site.

    5. Restart the WebLogic server.

    Configuring a JDBC Connection Pool

    If your application uses a JDBC data source, you must first configure a JDBC connection pool in the WebLogic server before you can createa JDBC data source. Use the WebLogic Administration Console to configure a JDBC connection pool.

    1. From your web browser, start the WebLogic Administration Console by entering the URL http://hostname:portnumber/console/, where hostname is the name of the system where your WebLogic server is installed andportnumberis the port onwhich the server is running

    The default port is 7001.

    2. Enter your user name and password.

    3. Click to expand the Services > JDBC node on the left panel of the Administration Console.

    4. Right-click the Connection Pools node and select Configure a New JDBC Connection Pool.

    The JDBC Connection Pool Assistant opens in the right pane.

    5. From the Database Type list, select the database type and the corresponding Database Driver that your application uses to connect tothe database. Click Continue.

    6. Fill in the Data Connection Properties dialog box, and then click Continue.

    The following figure shows a connection pool for the DataboundComponents_MySQL sample application.

    2

    http://dev.mysql.com/downloads/connector/j/3.1.htmlhttp://dev.mysql.com/downloads/connector/j/3.1.html
  • 7/28/2019 Web Logic Deploy

    3/7

    Figure 1 : Connection Pool Properties

    7. In the Test Database Connection dialog box, verify the connection properties and then click Test Driver Configuration.

    If the test is successful, the Create and Deploy page is displayed. If the test is unsuccessful, an error message is displayed at the top ofthe page. Check the values on the page and corect any errors, and then test the connection again.

    8. Click the Create and Deploy button.

    Your new connection pool appears in a table on the right pane and under the Connection Pools node on the left pane.

    Configuring a JDBC Data Source

    If the application you want to deploy to the WebLogic server uses a JDBC data source, you must configure that JDBC data source before

    you can deploy the application to the WebLogic server. After you configure a database connection pool, you need to configure the datasource for that connection.

    1. In the WebLogic Administration Console, expand the Services > JDBC node on the left panel.

    2. Click the Data Sources node on the left pane and click Configure a new JDBC Data Source on the right pane.

    The Configure a JDBC Data Source page appears on the right pane.

    3. Enter a name and the JNDI name for the JDBC data source.

    3

  • 7/28/2019 Web Logic Deploy

    4/7

    These names can be any names of your choosing. The JNDI name you choose will be used when you modify the reference resourcein the WAR file later in this tutorial.

    4. Click Continue to associate the JDBC data source with a connection pool.

    5. From the Connection Pool dropdown list, select the connection pool to which you want to associate your newly created JDBC datasource. Click Continue.

    6. Select the server to which you want to target the new JDBC data source.

    For this tutorial, select the same server to which you plan to deploy the application.

    7. Click Create.

    The newly created data source appears in a table in the right pane, as shown in the figure below. It also appears under the Services >Data Sources node in the left pane.

    Figure 2 : New JDBC Data Resource

    Using the Builder Tool to Modify the WAR File

    You must have the WebLogic application server running and the WebLogic Builder tool must be connected to that server to complete thistutorial.

    1. Start the WebLogic Builder tool.

    From the BEA WebLogic Workshop, you can start the WebLogic Builder tool choosing Tools Menu > WebLogicServer > WebLogicBuilder. Alternatively, in a Microsoft Windows XP system, click Start menu and choose All Programs > BEA WebLogic Platform >Other Development Tools > WebLogic Builder to start the WebLogic Builder. In UNIX based platforms, use theBEA-home/

    weblogic81/server/bin/startWLBuilder.sh command script to start WebLogic Builder.

    2. Connect the WebLogic Builder tool to your WebLogic server instance.

    The WebLogic Builder window appears as shown in the following figure. The status line at the bottom of the window should sayConnected. If it does not, choose Tools > Connect to Server and type the necessary information to connect to your deploymentserver.

    4

  • 7/28/2019 Web Logic Deploy

    5/7

    Figure 3 : WebLogic Builder Tool

    3. Click File > Open to modify the WAR file you exported from the IDE.

    4. Click J2EE References node on the left pane and select the Resource Reference tab on the right pane.

    5. Select the Reference name that you need to modify. For our example, select jdbc/Travel and click Edit.

    6. In the JNDI name text field, type the JNDI name of the JDBC data source you created in an earlier step in this tutorial.

    Figure 4 below, shows the JNDI name used for the DataboundComponents_MySQL sample application.

    Figure 4 : Edit Resource References

    7. Click OK.

    8. If your application uses Enterprise Java Beans (EJB) references, click on the EJB Refs tab to add them.

    9. Choose File > Save to save all your changes to the application's WAR file.

    Deploying the Application to the WebLogic Server

    You can now deploy your application's modified WAR file to the WebLogic server.

    1. In the WebLogic Builder, select the application's WAR file on the left pane and choose Tools > Deploy Module.

    A dialog box similar to the following appears.

    5

  • 7/28/2019 Web Logic Deploy

    6/7

    Figure 5 : The Deploy Module Dialog Box

    2. Click the Deploy Module button.The dialog box closes. The message that your WAR file's descriptors successfully loaded appears in the Builder Messages pane at thebottom of the Builder Tool. The application has been deployed to your WebLogic server.

    3. Test your application by opening a web browser and entering the URL http://hostname:portnumber/your-app, wherehostname is the name of your WebLogic server,portnumberis port on which the server is running, and your-app is the name ofyour application.

    For example, the DataboundComponents_MySQL application deployed to a WebLogic server installed on a localhost and using thedefault port number of 7001, you type http://localhost:7001/DataboundComponents_MySQL . The following figureshows the deployed Databound Components application.

    Figure 6 : Testing the Databound Components Application

    See Also:

    q J2EE web siteq BEA WebLogic application server documentationq Deploying to Sun Java System Application Serverq Using Databound Components to Access Databases

    6

    http://java.sun.com/products/j2ee/http://e-docs.bea.com/wls/docs81/index.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/appserverdeploy.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/databoundcomponents.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/databoundcomponents.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/appserverdeploy.htmlhttp://e-docs.bea.com/wls/docs81/index.htmlhttp://java.sun.com/products/j2ee/
  • 7/28/2019 Web Logic Deploy

    7/7

    This page was last modified: February 10, 2006

    Sun and Third-party Trademarked Terminology

    The following Sun trademarked terms might be used in the Sun Java(tm) Studio Creator tutorials:

    q Sun Java Studio Creator integrated development environment (IDE)q Sun Java System Application Server version number(Application Server)q Java Platform, Standard Edition technology (Java SE(tm) platform)q JavaServer(tm) Faces technologyq JavaServer Pages(tm) technology (JSP(tm) technology)q Sun Java System Web Server version number(Web Server)q Java Database Connectivity software (JDBC software)q Enterprise JavaBeans(tm) specification (EJB(tm) specification)q Solaris(tm) Operating System software (Solaris OS software)

    The following third-party trademarked terms might be used in the Sun Java Studio Creator tutorials:

    q UNIX(R) softwareq SPARC(R) processor

    Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

    Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. Inparticular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries.

    U.S. Government Rights - Commercial software.

    Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and itssupplements. Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and the Java Coffee Cup logo are trademarks orregistered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.This product is covered and controlled by U.S. Export Controllaws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime enduses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entitiesidentified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictlyprohibited.

    Note: Sun is not responsible for the availability of third-party web sites mentioned in this document and does not endorse and is not responsibleor liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible orliable for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods, or servicesavailable on or through any such sites or resources.

    Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, tats-Unis. Tous droits rservs.

    Sun Microsystems, Inc. dtient les droits de proprit intellectuels relatifs la technologie incorpore dans le produit qui est dcrit dans cedocument. En particulier, et ce sans limitation, ces droits de proprit intellectuelle peuvent inclure un ou plus des brevets amricains lists l'adresse http://www.sun.com/patents et un ou les brevets supplmentaires ou les applications de brevet en attente aux tats-Unis et dans lesautres pays. L'utilisation est soumise aux termes de la Licence. Sun, Sun Microsystems, le logo Sun, Java et le logo Java Coffee Cup sont desmarques de fabrique ou des marques dposes de Sun Microsystems, Inc. aux tats-Unis et dans d'autres pays.Ce produit est soumis lalgislation amricaine en matire de contrle des exportations et peut tre soumis la rglementation en vigueur dans d'autres pays dans ledomaine des exportations et importations. Les utilisations, ou utilisateurs finaux, pour des armes nuclaires,des missiles, des armes biologiques

    et chimiques ou du nuclaire maritime, directement ou indirectement, sont s trictement interdites. Les exportations ou rexportations vers lespays sous embargo amricain, ou vers des entits figurant sur les listes d'exclusion d'exportation amricaines, y compris, mais de manire nonexhaustive, la liste de personnes qui font objet d'un ordre de ne pas participer, d'une faon directe ou indirecte, aux exportations des produits oudes services qui sont rgis par la lgislation amricaine en matire de contrle des exportations et la liste de ressortissants spcifiquementdsigns, sont rigoureusement interdites.

    Sun Microsystems n'est pas responsable de la disponibilit de tiers emplacements d'enchanement mentionns dans ce document et n'approuvepas et n'est pas responsable ou iresponsable d'aucun contenu, de la publicit, de produits, ou d'autres matriaux dessus ou fournis par de telsemplacements ou ressources. Sun ne sera pas responsable ou iresponsable d'aucuns dommages ou perte causs ou allgus pour tre caus parou en liaison avec l'utilisation de ce produit ou la confiance dans des tels contenu, marchandises, ou services disponibles sur ou par des telsemplacements ou ressources.

    7