Recipe 2.9 Using WebLogic Builder to Deploy a Web ApplicationProblemYou want to use WebLogic Builder to deploy a web application. Solution
WebLogic Builder
Discussion
WebLogic Builder is a graphical tool that installs with WebLogic Server 7. It can be used to edit deployment descriptor files such as
web.xml
and
weblogic.xml
, as well as for deploying web applications to a server. Using WebLogic Builder, you can
You can launch WebLogic Builder on Windows from either the "Start" menu or the command line. The start script for Builder is at: <BEA_HOME>/weblogic700/server/bin/startWLBuilder.cmd (or startWLBuilder.sh on Unix). <BEA_HOME> is the directory where WebLogic Server 7.0 is installed.
It is easy to open up and edit the deployment descriptor for a web application in WebLogic Builder. Go to the File
The result is the window depicted in Figure 2-12. The navigation tree in the
Figure 2-12. Opening a WAR file in WebLogic Builder
You can add or delete elements for servlets, servlet mappings, and filters, for instance. The changes are
The "Deploy Module" window indicates whether the application is already deployed. Figure 2-13 shows this window. If you have already deployed the application, you can still make deployment-descriptor changes in Builder, then deploy the application again from the "Tools" menu. WebLogic Builder
Figure 2-13. WebLogic Builder's Deploy Module window
WebLogic Builder does not show any JSP files that may be part of the web application. It will show any servlet mappings that are associated with JSP files. See AlsoRecipe 2.3, Recipe 2.7, Recipe 2.8, and Recipe 2.10; WebLogic's Server 7.0 programmer documentation: http://e-docs.bea.com/wls/docs70/programming.html; the local WebLogic Builder Help documentation: <BEA_HOME>\weblogic700\server\builder\index.html . |
Recipe 2.10 Using the weblogic.DeployerCommand-Line ToolProblemYou want to use the command line to deploy a web application on WebLogic Server 7.0. SolutionUse the Java-based weblogic.Deployer command-line utility, which is installed with WebLogic Server 7.0. Discussion
For developers or administrators who need to use the command line or shell scripts for deploying and redeploying web applications, WebLogic Server 7.0 provides the Java-based
Deployer
utility. This utility accomplishes the same
The Deployer utility is a Java-based program that requires the following JAR file on your classpath before the program can run: <BEA_HOME>\server\lib\weblogic.jar . "><BEA_HOME> represents the directory where WebLogic Server 7.0 was installed. The following command-line script on a Windows NT 4.0 machine redeploys the cookbook.war web application on a server named bwpserver :
java -cp k:\bea\weblogic700\server\lib\weblogic.jar;
%CLASSPATH% weblogic.Deployer
-adminurl http://localhost:7001
-user bwperry -name cookbook -source .\dist\cookbook.war
-targets bwpserver -activate
This command-line invocation deploys the web application represented by the archive file
cookbook.war
, so the application is now available to receive
This command-line invocation deactivates (makes unavailable) an existing web application on the server bwpserver . It prompts for the user password first, unless you add the -password option to the command line:
java -cp k:\bea\weblogic700\server\lib\weblogic.jar;
%CLASSPATH% weblogic.Deployer
-adminurl http://localhost:7001
-user bwperry -name cookbook
-targets bwpserver -deactivate
The
-cp
option specifies the classpath to use for running the
Deployer
Java utility, and must include the
weblogic.jar
JAR file. The
-adminurl
switch specifies the administration server (the default value is
http://localhost:7001
, so it does not have to be included here). The
-name
option specifies the name of the application to be deactivated, and the
-targets
option
java -cp k:\bea\weblogic700\server\lib\weblogic.jar;
%CLASSPATH% weblogic.Deployer
-user bwperry -name cookbook -activate
This time, the -adminurl and -targets options were omitted. The default values for these switches are http://localhost:7001 and all current targets (if the developer is redeploying an existing application), respectively. If the application is being deployed for the first time, the default target for the -targets option is the administration server. It is easier to run shell commands from a batch file, because there is less typing for complicated command-line programs and the shell scripts can be permanently saved. Example 2-7 is the first example rewritten as a batch file on Windows NT 4.0. Example 2-7. Deploying an application@echo off set WL_HOME=K:\bea\weblogic700 set BEA_CLASSPATH=%WL_HOME%\server\lib\weblogic.jar;%CLASSPATH% java -cp %BEA_CLASSPATH% weblogic.Deployer -adminurl http://localhost:7001 -user bwperry -name cookbook -source .\dist\cookbook.war -targets bwpserver -activate
This batch file sets two environment
H:\book\cookbook>deploy The resulting console output looks like this. Enter a password for the user "bwperry":bwpserver_1968 Operation started, waiting for notifications... .... #TaskID Action Status Target Type Application Source 15 Activate Success bwpserver Server cookbook H:\book\ cookbook\.\dist\cook See AlsoRecipe 2.3 and Recipe 2.5; Recipe 2.7-Recipe 2.9; WebLogic's Server 7.0 programmer documentation: http://e-docs.bea.com/wls/docs70/programming.html. |