Administration Guide

 Previous Next Contents View as PDF  

Using the WebLogic Java Utilities

WebLogic provides several Java programs that simplify installation and configuration tasks, provide services, and offer convenient shortcuts. The following sections describe each Java utility provided with WebLogic Server. The command-line syntax is specified for all utilities and, for some, examples are provided.

To use these utilities you must correctly set your CLASSPATH. For more information, see "Setting the Classpath."

 


AppletArchiver

The AppletArchiver utility runs an applet in a separate frame, keeps a record of all of the downloaded classes and resources used by the applet, and packages these into either a .jar file or a .cab file. (The cabarc utility is available from Microsoft.)

Syntax

$ java utils.applet.archiver.AppletArchiver URL filename

Argument

Definition

URL

URL for the applet.

filename

Local filename that is the destination for the .jar/.cab archive.


 

 


CertGen

The CertGen utility generates certificates that should only be used for demonstration or testing purposes and not in a production environment.

Syntax

$ java utils.CertGen password certfile keyfile [export]

Argument

Definition

password

Defines the password for the private key.

certfile

Defines the directory in which to copy the generated certificate file.

keyfile

Defines the directory in which to copy the generated private key file.

export

By default, the CertGen utility generates domestic strength certificates. Specify the [export] option if you want the tool to generate export strength certificates.


 

Example

To generate a certificate:

  1. Copy the following files to the directory in which you run the CertGen tool:

  2. Enter the following command to generate certificate files named testcert with private key files named testkey:
$ java utils.CertGen mykeypass testcert testkey
Creating Domestic Key Strength - 1024
Encoding
................................................................
................................................................
................................................................
Created Private Key files - testkey.der and testkey.pem
Encoding
................................................................
................................................................
................................................................
Created Certificate files - testcert.der and testcert.pem
................................................................

 


ClientDeployer

You use weblogic.ClientDeployer to extract the client-side JAR file from a J2EE EAR file, creating a deployable JAR file. The weblogic.ClientDeployer class is executed on the Java command line with the following syntax:

java weblogic.ClientDeployer ear-file client

The ear-file argument is an expanded directory (or Java archive file with a .ear extension) that contains one or more client application JAR files.

For example:

java weblogic.ClientDeployer app.ear myclient

where app.ear is the EAR file that contains a J2EE client packaged in myclient.jar.

Once the client-side JAR file is extracted from the EAR file, use the weblogic.j2eeclient.Main utility to bootstrap the client-side application and point it to a WebLogic Server instance as follows:

java weblogic.j2eeclient.Main clientjar URL [application args]

For example

java weblogic.j2eeclient.Main helloWorld.jar t3://localhost:7001 Greetings

 


Conversion

If you have used an earlier version of WebLogic, you must convert your weblogic.properties files. Instructions for converting your files using a conversion script are available in the Administration Console Online Help section called "Conversion."

 


der2pem

The der2pem utility converts an X509 certificate from DER format to PEM format. The .pem file is written in the same directory as the source .der file.

Syntax

$ java utils.der2pem derFile [headerFile] [footerFile]

Argument

Description

derFile

The name of the file to convert. The filename must end with a .der extension, and must contain a valid certificate in .der format.

headerFile

The header to place in the PEM file. The default header is "-----BEGIN CERTIFICATE-----".

Use a header file if the DER file being converted is a private key file, and create the header file containing one of the following:

  • "-----BEGIN RSA PRIVATE KEY-----" for an unencrypted private key.

  • "-----BEGIN ENCRYPTED PRIVATE KEY-----" for an encrypted private key.

Note: There must be a new line at the end of the header line in the file.

footerFile

The header to place in the PEM file. The default header is "-----END CERTIFICATE-----".

Use a footer file if the DER file being converted is a private key file, and create the footer file containing one of the following in the header:

  • "-----END RSA PRIVATE KEY-----" for an unencrypted private key.

  • "-----END ENCRYPTED PRIVATE KEY-----" for an encrypted private key.

Note: There must be a new line at the end of the header line in the file.


 

Example

$ java utils.der2pem graceland_org.der
Decoding
................................................................

 


dbping

The dbping command-line utility tests the connection between a DBMS and your client machine via a JDBC driver. You must complete the installation of the driver before attempting to use this utility. For more information on how to install a driver, see WebLogic jDrivers.

Syntax

$ java -Dbea.home=license_location utils.dbping DBMS user password DB

Argument

Definition

license_location

The directory containing your WebLogic Server license (license.bea). For example, d:\beaHome\. Required only if using a BEA-supplied JDBC driver.

DBMS

Choose one of the following for your JDBC driver:

WebLogic jDriver for Microsoft SQL Server:
  MSSQLSERVER4

WebLogic jDriver for Oracle:
  ORACLE

Oracle Thin Driver:
  ORACLE_THIN

Sybase JConnect driver:
  JCONNECT

Sybase JConnect 5.5 (JDBC 2.0) driver:
  JCONN2

user

Valid username for login. Use the same values you use with isql or sqlplus.

password

Valid password for the user. Use the same values you use with isql or sqlplus.

DB

Name of the database. Use the following format, depending on which JDBC driver you use:

WebLogic jDriver for Microsoft SQL Server:
   DBNAME@HOST:PORT

WebLogic jDriver for Oracle:
  DBNAME

Oracle Thin Driver:
  HOST:PORT:DBNAME

Sybase JConnect driver: JCONNECT:
  
HOST:PORT/DBNAME

Sybase JConnect driver: JCONN2:
  
HOST:PORT/DBNAME


Where:

  • HOST is the name of the machine hosting the DBMS,

  • PORT is port on the database host where the DBMS is listening for connections, and

  • DBNAME is the name of a database on the DBMS. (For Oracle, this is the name of a DBMS defined in the tnsnames.ora file.)


 

Example

$ C:\bea\weblogic700b\samples\server\config\examples>java utils.dbping ORACLE_THIN scott tiger lcdbsol1:1561:lcs901

**** Success!!! ****

You can connect to the database in your app using:

java.util.Properties props = new java.util.Properties();
props.put("user", "scott");
props.put("password", "tiger");

java.sql.Driver d = (java.sql.Driver)Class.forName("oracle.jdbc.driver.OracleD
river").newInstance();
java.sql.Connection conn = d.connect("jdbc:oracle:thin:@lcdbsol1:1561:lcs901",
props);

// This mode is superior, especially in serverside classes because
// it avoids DriverManager calls are class synchronized, and will
// bottleneck any other JDBC in the server, even already-running
// connections, because all JDBC drivers useDriverManager.println()
// to log info and exceptions, and that call is also class    synchronized.
// For repeated connecting, a single driver instance can be re-used.

**** or ****

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
java.sql.Connection conn =
Driver.connect("jdbc:oracle:thin:@lcdbsol1:1561:lcs901", "scott", "tiger");

**** or ****

java.util.Properties props = new java.util.Properties();
props.put("user", "scott");
props.put("password", "tiger");
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
java.sql.Connection conn =
Driver.connect("jdbc:oracle:thin:@lcdbsol1:1561:lcs901", props);

 


Deployer

weblogic.Deployer deploys J2EE applications and components to WebLogic Servers. For additional information, see Deployment Tools and Procedures.

The weblogic.Deployer utility is new in WebLogic Server 7.0, and replaces the earlier weblogic.deploy utility, which has been deprecated. For more information about the deprecated weblogic.deploy utility, see "Deploying Applications" in the WebLogic Server Administration Guide.

Syntax

% java weblogic.Deployer [options] [-activate|-deactivate|-remove|-cancel|-list] [files]

Actions (select one of the following)


 

Action

Description

activate

Deploys or redeploys the application specified by -name to the servers specified by -targets.

cancel

Attempts to cancel the task identified by -id.

deactivate

Deactivates the application on the target servers. Deactivation suspends the deployed components, leaving staged data in place in anticipation of subsequent reactivation. This command only works in the two-phase deployment protocol.

delete_files

Removes files specified in the file list and leaves the application activated. This is valid only for unarchived applications. You must specify target servers.

deploy

A convenient alias for -activate.

examples

Displays example usages of the tool.

help

Prints a help message.

list

Lists the status of the task identified by -id.

remove

Physically removes the application and any staged data from the target servers. The components are deactivated and the targets are removed from the applications configuration. If you remove the application entirely, the associated MBeans are also deleted from the system configuration. This command only works with the two-phase deployment model.

undeploy

A convenient alias for -unprepare.

unprepare

Deactivates and unloads classes for the application identified by -name on the target servers, leaving the staged application files in a state where they may be edited or quickly reloaded.

upload

Transfers the specified source file(s) to the administration server. Use this option when you are on a remote system and want to deploy an application that resides on the remote system. The application files are uploaded to the WebLogic Server administration server prior to distribution to named target servers.

version

Prints version information.


 

Options


 

Option

Description

adminurl

https://<server>:<port> is the URL of the administration server. Default is http://localhost:7001.

debug

Turns on debug messages in the output log.

external_stage

Sets the stagingMethod attribute on the application Mbean when it is created so that the application will not be staged but the value of the staging path will be used when preparing the application.

id

The task identifier -id is a unique identifier for the deployment task. You can specify an -id with the -activate, -deactivate, or -remove commands, and use it later as an argument to -cancel or -list. Make sure the -id is unique from all other existing deployment tasks. The system generates an -id if you do not specify one.

name

The application -name specifies the name of the application being deployed. This can be the name of an existing, configured application or the name to use when creating a new configuration.

nostage

Sets the no-staging attribute on the ApplicationMBean, indicating that the application does not require staging. The system assumes the application already resides at the location specified by its Path attribute on the target servers.

nowait

Once the action is initiated, the tool prints the task id and exits. This is used to initiate multiple tasks and then monitor them later using the -list action.

password

Specifies the password on the command line. If you do not provide a password, you will be prompted for one.

remote

Signals that weblogic.Deployer is not running on the same machine as the administration server and that the source path should be passed through unchanged because it represents the path on the remote server.

source

Archive or directory, specifies the location of the file or directory to be deployed. Use this option to set the application Path. The source option should reference the root directory or archive being deployed. If using upload, the source path is relative to the current directory. Otherwise, it is relative to the administration server root directory—the directory where the config.xml file resides.

stage

Sets the stagingMethod attribute on the application when it is created so that the application will always be staged. This value overrides the stagingMethod attribute on any targeted servers.

targets

<server 1>,...<component>@<server N>, displays a comma-separated list of the server and/or cluster names. Each target may be qualified with a J2EE component name. This enables different components of the archive to deployed on different servers.

When specified for an application that is already deployed, this list is an addition to the existing targets. If any existing targets are again specified, the application is redeployed on those targets and deployed on the new ones.

timeout

Seconds. Specifies the maximum time in seconds to wait for the completion of the deployment task. When the time expires, weblogic.Deployer prints out the current status of the deployment and exits.

user

User name.

verbose

Displays additional progress messages.

Examples

Examples of weblogic.Deployer commands:

Deploying a New Application

java weblogic.Deployer -adminurl http://admin:7001 -name app -source /myapp/app.ear -targets server1,server2 -activate

Redeploying an Application

java weblogic.Deployer -adminurl http://admin:7001 -name app -activate

Redeploying Part of an Application

java weblogic.Deployer -adminurl http://admin:7001 -name appname -targets server1,server2 -activate jsps/*.jsp

Deactivating an Application

java weblogic.Deployer -adminurl http://admin:7001 -name app -targets server1 -deactivate 

Undeploying an Application

java weblogic.Deployer -adminurl http://admin:7001 -name app -targets server -remove -id tag 

Canceling a Deployment Task

java weblogic.Deployer -adminurl http://admin:7001 -cancel -id tag

Listing All Deployment Tasks

java weblogic.Deployer -adminurl http://admin:7001 -list

 


EJBGen

EJBGen is an Enterprise JavaBeans 2.0 code generator. You can annotate your Bean class file with javadoc tags and then use EJBGen to generate the Remote and Home classes and the deployment descriptor files for an EJB application, reducing to one the number of EJB files you need to edit and maintain.

If you have installed BEA WebLogic 7.0 examples, see SAMPLES_HOME\server\src\examples\ejb20\ejbgen\ for an example application that uses EJBGen.

For complete documentation of this tool, see EJBGen in WebLogic Server EJB Utilities.

 


getProperty

The getProperty utility gives you details about your Java setup and your system. It takes no arguments.

Syntax

$ java utils.getProperty

Example

$ java utils.getProperty
-- listing properties --
user.language=en
java.home=c:\java11\bin\..
awt.toolkit=sun.awt.windows.WToolkit
file.encoding.pkg=sun.io
java.version=1.1_Final
file.separator=\
line.separator=
user.region=US
file.encoding=8859_1
java.vendor=Sun Microsystems Inc.
user.timezone=PST
user.name=mary
os.arch=x86
os.name=Windows NT
java.vendor.url=http://www.sun.com/
user.dir=C:\weblogic
java.class.path=c:\weblogic\classes;c:\java\lib\cla...
java.class.version=45.3
os.version=4.0
path.separator=;
user.home=C:\

 


ImportPrivateKey

The ImportPrivateKey utility is used to load a private key into a private keystore file.

Syntax

$ java utils.ImportPrivateKey keystore keystorepass alias keypass certfile keyfile

Argument

Definition

keystore

Defines the name of the keystore file. A new keystore is created if one does not exist.

keystorepass

Defines the password to open the keystore file.

alias

Defines the name that is used to look up certificates and keys in the keystore.

keypass

Defines the password used to unlock the private key file and to protect the private key in the keystore.

certfile

The name of the certificate associated with the private key.

keyfile

The name of the file holding the protected private key.


 

Example

Use the following steps to:

  1. Copy the WL_HOME/server/lib/CertGenCA.der file and the WL_HOME/server/lib/CertGenCAkey.der file to your working directory.

  2. Use the utils.CertGen utility to generate a certificate and private key. See Using the CertGen Tool.
java utils.CertGen mykeypass testcert testkey
Creating Domestic Key Strength - 1024
Encoding
................................................................
................................................................
................................................................
Created Private Key files - testkey.der and testkey.pem
Encoding
................................................................
................................................................
................................................................
Created Certificate files - testcert.der and testcert.pem
................................................................

  1. Convert the certificate from DER format to PEM format.
D:\bea2\weblogic700\samples\server\src>java utils.der2pem CertGenCA.der
Encoding
................................................................
................................................................

  1. Concatenate the certificate and the Certificate Authority (CA).
D:\bea2\weblogic700\samples\server\src>type testcert.pem CertGenCA.pem >> newcerts.pem

  1. Create a new keystore named mykeystore and load the private key located in the testkey.pem file.
D:\bea2\weblogic700\samples\server\src>java utils.ImportPrivateKey mykeystore mypasswd mykey mykeypass newcerts.pem testkey.pem
Keystore file not found, creating it

 


logToZip

The logToZip utility searches an HTTP server log file in common log format, finds the Java classes loaded into it by the server, and creates an uncompressed .zip file that contains those Java classes. It is executed from the document root directory of your HTTP server.

To use this utility, you must have access to the log files created by the HTTP server.

Syntax

$ java utils.logToZip logfile codebase zipfile

Argument

Definition

logfile

Required. Fully-qualified pathname of the log file.

codebase

Required. Code base for the applet, or "" if there is no code base. By concatenating the code base with the full package name of the applet, you get the full pathname of the applet (relative to the HTTP document root).

zipfile

Required. Name of the .zip file to create. The resulting .zip file is created in the directory in which you run the program. The pathname for the specified file can be relative or absolute. In the examples, a relative pathname is given, so the .zip file is created in the current directory.


 

Examples

The following example shows how a .zip file is created for an applet that resides in the document root itself, that is, with no code base:

$ cd /HTTP/Serv/docs
$ java utils.logToZip /HTTP/Serv/logs/access "" app2.zip

The following example shows how a .zip file is created for an applet that resides in a subdirectory of the document root:

C:\>cd \HTTP\Serv
C:\HTTP\Serv>java utils.logToZip \logs\applets\classes app3.zip

 


MulticastTest

The MulticastTest utility helps you debug multicast problems when configuring a WebLogic Cluster. The utility sends out multicast packets and returns information about how effectively multicast is working on your network. Specifically, MulticastTest displays the following types of information via standard output:

  1. A confirmation and sequence ID for each message sent out by this server.

  2. The sequence and sender ID of each message received from any clustered server, including this server.

  3. A missed-sequenced warning when a message is received out of sequence.

  4. A missed-message warning when an expected message is not received.

To use MulticastTest, start one copy of the utility on each node on which you want to test multicast traffic.

Warning: Do NOT run the MulticastTest utility by specifying the same multicast address (the -a parameter) as that of a currently running WebLogic Cluster. The utility is intended to verify that multicast is functioning properly before starting your clustered WebLogic Servers.

For information about setting up multicast, see the configuration documentation for the operating system/hardware of the WebLogic Server host. For more information about configuring a cluster, see Using WebLogic Server Clusters.

Syntax

$ java utils.MulticastTest -n name -a address [-p portnumber]
[-t timeout] [-s send]

Argument

Definition

-n name

Required. A name that identifies the sender of the sequenced messages. Use a different name for each test process you start.

-a address

Required. The multicast address on which: (a) the sequenced messages should be broadcast; and (b) the servers in the clusters are communicating with each other. (The default for any cluster for which a multicast address is not set is 237.0.0.1.)

-p portnumber

Optional. The multicast port on which all the servers in the cluster are communicating. (The multicast port is the same as the listen port set for WebLogic Server, which defaults to 7001 if unset.)

-t timeout

Optional. Idle timeout, in seconds, if no multicast messages are received. If unset, the default is 600 seconds (10 minutes). If a timeout is exceeded, a positive confirmation of the timeout is sent to stdout.

-s send

Optional. Interval, in seconds, between sends. If unset, the default is 2 seconds. A positive confirmation of each message sent out is sent to stdout.


 

Example

$ java utils.MulticastTest -N server100 -A 237.155.155.1
Set up to send and receive on Multicast on Address 237.155.155.1 on port 7001
Will send a sequenced message under the name server100 every 2 seconds.
Received message 506 from server100
Received message 533 from server200
I (server100) sent message num 507
Received message 507 from server100
Received message 534 from server200
I (server100) sent message num 508
Received message 508 from server100
Received message 535 from server200
I (server100) sent message num 509
Received message 509 from server100
Received message 536 from server200
I (server100) sent message num 510
Received message 510 from server100
Received message 537 from server200
I (server100) sent message num 511
Received message 511 from server100
Received message 538 from server200
I (server100) sent message num 512
Received message 512 from server100
Received message 539 from server200
I (server100) sent message num 513
Received message 513 from server100

 


myip

The myip utility returns the IP address of the host.

Syntax

$ java utils.myip

Example

$ java utils.myip
Host toyboat.toybox.com is assigned IP address: 192.0.0.1

 


pem2der

The pem2der utility converts an X509 certificate from PEM format to DER format. The .der file is written in the same directory as the source .pem file.

Syntax

$ java utils.pem2der pemFile

Argument

Description

pemFile

The name of the file to be converted. The filename must end with a .pem extension, and it must contain a valid certificate in .pem format.


 

Example

$ java utils.pem2der graceland_org.pem
Decoding
................................................................
................................................................
................................................................
................................................................
................................................................

 


Schema

The Schema utility lets you upload SQL statements to a database using the WebLogic JDBC drivers. For additional information about database connections, see Programming WebLogic JDBC.

Syntax

$ java utils.Schema driverURL driverClass [-u username]
[-p password] [-verbose] SQLfile

Argument

Definition

driverURL

Required. URL for the JDBC driver.

driverClass

Required. Pathname of the JDBC driver class.

-u username

Optional. Valid username.

-p password

Optional. Valid password for the user.

-verbose

Optional. Prints SQL statements and database messages.

SQLfile

Required. Text file with SQL statements.


 

Example

The following code shows a Schema command line for the examples.utils package:

D:\bea\weblogic700\samples\server\src>java utils.Schema
"jdbc:pointbase:server://localhost/demo"
"com.pointbase.jdbc.jdbcUniversalDriver" -u "examples"
-p "examples" examples/utils/ddl/demo.ddl
utils.Schema will use these parameters:
url: jdbc:pointbase:server://localhost/demo
driver: com.pointbase.jdbc.jdbcUniversalDriver
dbserver: null
user: examples
password: examples
SQL file: examples/utils/ddl/demo.ddl

 


showLicenses

The showLicenses utility displays license information about BEA products installed in this machine.

Syntax

$ java -Dbea.home=license_location utils.showLicenses

Argument

Description

license_location

The fully qualified name of the directory where the license.bea file exists.


 

Example

$ java -Dbea.home=d:\bea utils.showLicense

 


system

The system utility displays basic information about your computer's operating environment, including the manufacturer and version of your JDK, your CLASSPATH, and details about your operating system.

Syntax

$ java utils.system

Example

$ java utils.system
* * * * * * * java.version * * * * * * *
1.1.6

* * * * * * * java.vendor * * * * * * *
Sun Microsystems Inc.

* * * * * * * java.class.path * * * * * * *
\java\lib\classes.zip;\weblogic\classes;
\weblogic\lib\weblogicaux.jar;\weblogic\license
...

* * * * * * * os.name * * * * * * *
Windows NT

* * * * * * * os.arch * * * * * * *
x86

* * * * * * * os.version * * * * * * *
4.0

 


verboseToZip

When executed from the document root directory of your HTTP server, verboseToZip takes the standard output from a Java application run in verbose mode, finds the Java classes referenced, and creates an uncompressed.zip file that contains those Java classes.

Syntax

$ java utils.verboseToZip inputFile zipFileToCreate

Argument

Definition

inputFile

Required. Temporary file that contains the output of the application running in verbose mode.

zipFileToCreate

Required. Name of the .zip file to be created. The resulting .zip file is be created in the directory in which you run the program.


 

UNIX Example

$ java -verbose myapplication > & classList.tmp
$ java utils.verboseToZip classList.tmp app2.zip

NT Example

$ java -verbose myapplication > classList.tmp
$ java utils.verboseToZip classList.tmp app3.zip

 


version

The version utility displays version information about your installed WebLogic via stdout.

Syntax

$ java weblogic.Admin -url host:port -username username -password password VERSION

Example

$ java weblogic.Admin
-url localhost:7001 -username system -password foo VERSION

 


writeLicense

The writeLicense utility writes information about all your WebLogic licenses in a file called writeLicense.txt, located in the current directory. This file can then be emailed, for example, to WebLogic technical support.

Syntax

$ java utils.writeLicense -nowrite -Dweblogic.system.home=path

Argument

Definition

-nowrite

Required. Sends the output to stdout instead of writeLicense.txt.

-Dweblogic.system.home

Required. Sets WebLogic system home (the root directory of your WebLogic installation).

This argument is required unless you are running writeLicense from your WebLogic system home.


 

Examples

$ java utils.writeLicense -nowrite

Example of UNIX Output

* * * * * * System properties * * * * * *

* * * * * * * java.version * * * * * * *
1.1.7

* * * * * * * java.vendor * * * * * * *
Sun Microsystems Inc.

* * * * * * * java.class.path * * * * * * *
c:\weblogic\classes;c:\weblogic\lib\weblogicaux.jar;
c:\java117\lib\classes.zip;c:\weblogic\license
...

Example of Windows NT Output

* * * * * * * os.name * * * * * * * 
Windows NT

* * * * * * * os.arch * * * * * * *
x86

* * * * * * * os.version * * * * * * *
4.0

* * * * * * IP * * * * * *
Host myserver is assigned IP address: 192.1.1.0

* * * * * * Location of WebLogic license files * * * * * *
No WebLogicLicense.class found

No license.bea license found in
weblogic.system.home or current directory

Found in the classpath: c:/weblogic/license/license.bea
Last Modified: 06/02/1999 at 12:32:12

* * * * * * Valid license keys * * * * * *
Contents:
Product Name : WebLogic
IP Address : 192.1.1.0-255
Expiration Date: never
Units : unlimited
key : b2fcf3a8b8d6839d4a252b1781513b9
...

* * * * * * All license keys * * * * * *
Contents:
Product Name : WebLogic
IP Address : 192.1.1.0-255
Expiration Date: never
Units : unlimited
key : b2fcf3a8b8d6839d4a252b1781513b9
...

* * * * * * WebLogic version * * * * * *
WebLogic Build: 4.0.x xx/xx/1999 10:34:35 #xxxxx

 

Back to Top Previous Next