bea.com | products | dev2dev | support | askBEA |
|
e-docs > WebLogic Server > WebLogic Server Command Reference > Using the WebLogic Server Java Utilities |
WebLogic Server Command Reference |
Using the WebLogic Server Java Utilities
WebLogic Server 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 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
................................................................
This utility compiles and validates a J2EE EAR file, an EJB JAR file or a WAR file for deployment.
For more information, see WebLogic Server EJB Tools.
java weblogic.appc [options] <EAR, JAR, or WAR file or directory>
If you have used a pre-6.0 version of WebLogic Server, 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);
DDInit is a utility for generating deployment descriptors for applications to be deployed on WebLogic Server. Target a module's archive or folder and DDInit uses information from the module's class files to create appropriate deployment descriptor files.
WebLogic Builder, the graphical user interface for generating and editing deployment descriptors, runs DDInit to generate deployment descriptors. See WebLogic Builder for more information.
In its command-line version, unlike in WebLogic Builder, DDInit writes new files that overwrite existing descriptor files. If META-INF (for EAR or EJB), or WEB-INF (for Web Applications), does not exist, DDInit creates it.
Specify the type of J2EE deployable for which you want deployment descriptors generated by using the DDInit command command specific to the type, as described below.
Target a JAR file or a folder containing files that you intend to archive as a JAR file, and EJBInit will generate the ejb-jar.xml and the weblogic-ejb-jar.xml files for the module.
java weblogic.marathon.ddinit.EJBInit <module>
EJBInit looks in folders under the target and finds EJBs (bean class, local or remote home, remote or local interface). Matches interfaces with beans, and determines from that match which home belongs to which bean. In the bean itself it looks for CMP filelds. then for relationships between entity beans. From information gathered in this way, EJBInit writes the deployment descriptors.
DDInit supports EJB 2.0. DDInit will provide accurate results for session beans from 1.1, but is not likely to work for EJB 1.1 entity beans.
Target a WAR file or a folder containing files that you intend to archive as a WAR file, and WebInit will create web.xml and weblogic.xml files for the module.
java weblogic.marathon.ddinit.WebInit <module>
Generate an application.xml and a weblogic-application.xml file for an EAR using this command. Target an existing EAR or a folder containing JAR or WAR files you intend to archive into an EAR file.
java weblogic.marathon.ddinit.EARInit <module>
In WebLogic Builder, EARInitlooks recursively at the entire tree under the targeted module. On the command line, you need to already have descriptors for the modules contained in the EAR. application.xml will account for the modules. The generated weblogic-application.xml will be an empty placeholder.
This output from this example describes building deployment descriptor files for ejb_st.jar.
D:\dev\smarticket5\smarticket\bin>java weblogic.marathon.ddinit.EJBInit ejb_st.jar
Found 4 classes that implement the EnterpriseBean interface
Discovered module type for D:\dev\smarticket5\smarticket\bin\ejb_st.jar
Found EJB components. Initializing descriptors
Creating desc for bean com.sun.j2ee.blueprints.smarticket.ejb.customer.CustomerEJB
*** found remote home: com.sun.j2ee.blueprints.smarticket.ejb.customer.CustomerHome
*** found remote interface: com.sun.j2ee.blueprints.smarticket.ejb.customer.Customer
Setting prim-key-class to 'java.lang.String'
Adding Entity bean 'CustomerEJB'
Creating desc for bean com.sun.j2ee.blueprints.smarticket.ejb.localeinfo.LocaleInfoEJB
*** found remote home: com.sun.j2ee.blueprints.smarticket.ejb.localeinfo.LocaleInfoHome
*** found remote interface: com.sun.j2ee.blueprints.smarticket.ejb.localeinfo.LocaleInfo
LocaleInfoEJB is a Stateless Session bean
Adding Session bean 'LocaleInfoEJB'
Creating desc for bean com.sun.j2ee.blueprints.smarticket.ejb.movieinfo.MovieInfoEJB
*** found remote home: com.sun.j2ee.blueprints.smarticket.ejb.movieinfo.MovieInfoHome
*** found remote interface: com.sun.j2ee.blueprints.smarticket.ejb.movieinfo.MovieInfo
MovieInfoEJB is a Stateless Session bean
Adding Session bean 'MovieInfoEJB'
Creating desc for bean com.sun.j2ee.blueprints.smarticket.ejb.ticketsales.TicketSalesEJB
*** found remote home: com.sun.j2ee.blueprints.smarticket.ejb.ticketsales.TicketSalesHome
*** found remote interface: com.sun.j2ee.blueprints.smarticket.ejb.ticketsales.TicketSales
TicketSalesEJB is a Stateful Session bean
Adding Session bean 'TicketSalesEJB'
Building module with newly created descriptors
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 host2ior utility obtains the Interoperable Object Reference (IOR) of a WebLogic Server.
java utils.host2ior (hostname) (port)
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>cat 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
Converts JHTML files to JSP files. Be sure to inspect results carefully, as this utility is intended to begin the conversion process and, given the unpredictability of the JHTML code, will not necessarily produce flawless translations.
Output is a new JSP file named after the original file.
The HTTP servlets that are auto-generated from JSP pages (when they are run in the server) differ from the regular HTTP servlets that are generated from JHTML. JSP servlets extend weblogic.servlet.jsp.JspBase, and so do not have access to the methods available to a regular HTTP servlet.
If your JHTML pages may reference these methods to access the servlet 'context' or 'config' objects, you will need to substitute these methods with the reserved words in JSP that represent these implicit objects.
If your JHTML uses variables that have the same name as the reserved words in JSP, the tool will output a warning. You will need to edit your Java code in the generated JSP page to change the variable name to something other than a reserved word.
java weblogic.utils.jhtml2jsp -d <directory> filename.jhtml
java weblogic.utils.jhtml2jsp filename.jhtml
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
Usage: java utils.t2dbtest username password server weblogic.t2.driver weblogic.t2.url #logins #queries tablename
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
The t3dbping utility tests a WebLogic JDBC connection to a DBMS via any two-tier JDBC driver. You must have access to a WebLogic Server Server and a DBMS to use this utility.
$ java utils.t3dbping WebLogicURL username password DBMS driverClass driverURL
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 Server 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