The execution of a Wlst Script can happen in the following three modes:
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>
This wlst.cmd:
FMW_HOME\oracle_common\common\bin\wlst.cmd
calls this one:
FMW_HOME\wlserver_10.3\common\bin\wlst.cmd
The script:
import sys
if len(sys.argv) > 1:
print sys.argv[1]+" from the console"
else:
print "Hello World from the script"
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
import sys
sys.argv = ['Hello World', 'arg2']
execfile('HelloWorld.py')
<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
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"/>