Você está na página 1de 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 integrated development 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 WebLogic Server 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 your application. 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 unfamiliar with the BEA WebLogic Server, read its documentation before 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 deploys successfully to the development container that is bundled with the IDE before you deploy your application to the WebLogic server. If your application uses JDBC data sources, you need to include the classpaths for their corresponding database drivers in the BEA WebLogic domain 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 Databound Components 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 applications developed with the Java Studio Creator IDE. You need to add these JAR files to the WebLogic server's classpath settings for the the application 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 r

jstl.jar standard.jar

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% where your-dir is 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 to start the domain is located at BEAhome\user_projects\domains\domain_name\startWebLogic.cmd, where BEAhome is where you installed the WebLogic server and domain-name is the name of the WebLogic domain you want to use. For UNIX and Linux platforms, the startup file is at BEAhome/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 the application is added in the WebLogic domain startup file. The following lines are added immediately before the CLASSPATH variable 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 create a 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 and portnumber is the port on which 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 to the 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.

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 of the 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 data source 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.

These names can be any names of your choosing. The JNDI name you choose will be used when you modify the reference resource in 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 data source. 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 this tutorial. 1. Start the WebLogic Builder tool. From the BEA WebLogic Workshop, you can start the WebLogic Builder tool choosing Tools Menu > WebLogicServer > WebLogic Builder. 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 the BEA-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 say Connected. If it does not, choose Tools > Connect to Server and type the necessary information to connect to your deployment server.

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.

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 the bottom 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, where hostname is the name of your WebLogic server, portnumber is port on which the server is running, and your-app is the name of your application. For example, the DataboundComponents_MySQL application deployed to a WebLogic server installed on a localhost and using the default port number of 7001, you type http://localhost:7001/DataboundComponents_MySQL. The following figure shows the deployed Databound Components application.

Figure 6 : Testing the Databound Components Application

See Also:
q q q q

J2EE web site BEA WebLogic application server documentation Deploying to Sun Java System Application Server Using Databound Components to Access Databases

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 q q q q q q q q

Sun Java Studio Creator integrated development environment (IDE) Sun Java System Application Server version number (Application Server) Java Platform, Standard Edition technology (Java SE(tm) platform) JavaServer(tm) Faces technology JavaServer Pages(tm) technology (JSP(tm) technology) Sun Java System Web Server version number (Web Server) Java Database Connectivity software (JDBC software) Enterprise JavaBeans(tm) specification (EJB(tm) specification) 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 q

UNIX(R) software 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. In particular, 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 its supplements. Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and the Java Coffee Cup logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.This product is covered and controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited. Note: Sun is not responsible for the availability of third-party web sites mentioned in this document and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable 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 services available 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 ce document. 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 les autres pays. L'utilisation est soumise aux termes de la Licence. Sun, Sun Microsystems, le logo Sun, Java et le logo Java Coffee Cup sont des marques de fabrique ou des marques dposes de Sun Microsystems, Inc. aux tats-Unis et dans d'autres pays.Ce produit est soumis la lgislation amricaine en matire de contrle des exportations et peut tre soumis la rglementation en vigueur dans d'autres pays dans le domaine 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 strictement interdites. Les exportations ou rexportations vers les pays sous embargo amricain, ou vers des entits figurant sur les listes d'exclusion d'exportation amricaines, y compris, mais de manire non exhaustive, la liste de personnes qui font objet d'un ordre de ne pas participer, d'une faon directe ou indirecte, aux exportations des produits ou des services qui sont rgis par la lgislation amricaine en matire de contrle des exportations et la liste de ressortissants spcifiquement dsigns, sont rigoureusement interdites. Sun Microsystems n'est pas responsable de la disponibilit de tiers emplacements d'enchanement mentionns dans ce document et n'approuve pas et n'est pas responsable ou iresponsable d'aucun contenu, de la publicit, de produits, ou d'autres matriaux dessus ou fournis par de tels emplacements ou ressources. Sun ne sera pas responsable ou iresponsable d'aucuns dommages ou perte causs ou allgus pour tre caus par ou en liaison avec l'utilisation de ce produit ou la confiance dans des tels contenu, marchandises, ou services disponibles sur ou par des tels emplacements ou ressources.

Você também pode gostar