![]() |
![]() |
e-docs > WebLogic Server > Administration Guide > Using the WebLogic Java Utilities |
Administration Guide
|
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."
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.)
$ java utils.applet.archiver.AppletArchiver URL filename
The CertGen utility generates certificates that should only be used for demonstration or testing purposes and not in a production environment.
$ java utils.CertGen password certfile keyfile [export]
$ 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
................................................................
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.
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:
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."
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.
$ java utils.der2pem derFile [headerFile] [footerFile]
$ java utils.der2pem graceland_org.der
Decoding
................................................................
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.
$ java -Dbea.home=license_location utils.dbping DBMS user password DB
$ 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);
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.
% java weblogic.Deployer [options] [-activate|-deactivate|-remove|-cancel|-list] [files]
Actions (select one of the following)
Examples of weblogic.Deployer commands:
java weblogic.Deployer -adminurl http://admin:7001 -name app -source /myapp/app.ear -targets server1,server2 -activate
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
java weblogic.Deployer -adminurl http://admin:7001 -name app -targets server1 -deactivate
java weblogic.Deployer -adminurl http://admin:7001 -name app -targets server -remove -id tag
java weblogic.Deployer -adminurl http://admin:7001 -cancel -id tag
java weblogic.Deployer -adminurl http://admin:7001 -list
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.
The getProperty utility gives you details about your Java setup and your system. It takes no arguments.
$ java utils.getProperty
$ 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:\
The ImportPrivateKey utility is used to load a private key into a private keystore file.
$ java utils.ImportPrivateKey keystore keystorepass alias keypass certfile keyfile
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
................................................................
D:\bea2\weblogic700\samples\server\src>java utils.der2pem CertGenCA.der
Encoding
................................................................
................................................................
D:\bea2\weblogic700\samples\server\src>type testcert.pem CertGenCA.pem >> newcerts.pem
D:\bea2\weblogic700\samples\server\src>java utils.ImportPrivateKey mykeystore mypasswd mykey mykeypass newcerts.pem testkey.pem
Keystore file not found, creating it
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.
$ java utils.logToZip logfile codebase zipfile
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
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:
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.
$ java utils.MulticastTest -n name -a address [-p portnumber]
[-t timeout] [-s send]
$ 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
The myip utility returns the IP address of the host.
$ java utils.myip
$ java utils.myip
Host toyboat.toybox.com is assigned IP address: 192.0.0.1
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.
$ java utils.pem2der 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. |
$ java utils.pem2der graceland_org.pem
Decoding
................................................................
................................................................
................................................................
................................................................
................................................................
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.
$ java utils.Schema driverURL driverClass [-u username]
[-p password] [-verbose] SQLfile
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
The showLicenses utility displays license information about BEA products installed in this machine.
$ java -Dbea.home=license_location utils.showLicenses
$ java -Dbea.home=d:\bea utils.showLicense
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.
$ java utils.system
$ 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
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.
$ java utils.verboseToZip inputFile zipFileToCreate
$ java -verbose myapplication > & classList.tmp
$ java utils.verboseToZip classList.tmp app2.zip
$ java -verbose myapplication > classList.tmp
$ java utils.verboseToZip classList.tmp app3.zip
The version utility displays version information about your installed WebLogic via stdout.
$ java weblogic.Admin -url host:port -username username -password password VERSION
$ java weblogic.Admin
-url localhost:7001 -username system -password foo VERSION
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.
$ java utils.writeLicense -nowrite -Dweblogic.system.home=path
$ java utils.writeLicense -nowrite
* * * * * * 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
...
* * * * * * * 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
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |