Table of Contents

WLST - Getting Started (Hello World)

About

The execution of a Wlst Script can happen in the following three modes:

How to

start the WLST console

From a shell with Java

Environment variable Path
CLASSPATH WebLogic Server classes
PATH WL_HOME\server\bin

Script to set both variables:

java
   [ -Dweblogic.security.SSL.ignoreHostnameVerification=true -Dweblogic.security.TrustKeyStore=DemoTrust ]
   weblogic.WLST
   [ -loadProperties propertyFilename ]
   [ -skipWLSModuleScanning ]
   [ [-i] filePath.py ]

where:

Example:

C:\Oracle\Middleware1035\wlserver_10.3\server\bin>java weblogic.WLST
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline>

From a shell script

This wlst.cmd:

FMW_HOME\oracle_common\common\bin\wlst.cmd

calls this one:

FMW_HOME\wlserver_10.3\common\bin\wlst.cmd

From Windows Start Menu: Weblogic Scripting Tool

Weblogic Scripting Tool Windows Menu

From Eclipse

Eclipse Wlst Console Start

Start an “Hello World” script

The script:

import sys

if len(sys.argv) > 1:
    print sys.argv[1]+" from the console" 
else:
    print "Hello World from the script"

From the shell

java weblogic.WLST HelloWorld.py "Hello World"
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Hello World from the console

From Eclipse

Eclipse Wlst Hello World

From the WLST console

import sys
sys.argv = ['Hello World', 'arg2']
execfile('HelloWorld.py')

From Ant

<property name="wls.lib.dir" location="C:/Oracle/Middleware1035/wlserver_10.3/server/lib" />
<path id="wls.classpath.id">
    <pathelement location="${wls.lib.dir}/weblogic.jar" />
</path>
<taskdef name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask" classpathref="wls.classpath.id" />
<target name="WlsHelloWorld">
    <wlst fileName="helloworld.py" classpathref="wls.classpath.id" arguments="'Hello World'"/>
</target>
ant WlsHelloWorld
Buildfile: D:\HelloWorld\build.xml

WlsHelloWorld:
     [wlst] 'Hello from the console

BUILD SUCCESSFUL
Total time: 3 seconds

Support

taskdef class weblogic.ant.taskdefs.management.WLSTTask cannot be found

taskdef class weblogic.ant.taskdefs.management.WLSTTask cannot be found
 using the classloader AntClassLoader[]

The classpath element must be added to the taskdef.

<taskdef name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask" classpathref="wls.classpath.id"/>

Documentation / Reference