是的,你可以使用另一個jython,但它不被支持,並有一些你必須忍受的deffects。我們使用jython 2.7a2。
這是我們用來啓動jyton的腳本。 它將改變緩存位置,並添加FKUTILS目錄到類路徑(這是我們存儲我們自己的模塊)
#!env sh
# Script to run jython with wlst as a module
# set up WL_HOME, the root directory of your WebLogic installation
WL_HOME="/produkter/oracle/weblogic/wlserver"
WLST_OFFLINE_LOG=/tmp/wlstblaj.$$.log
WLST_CACHEDIR=~/.jythoncachedir
FKUTILS="/program/fkuitls/"
JYTHON="/program/jython"
killed() {
echo ""
echo Cleaning up tempfile: $WLST_OFFLINE_LOG
rm -rf $WLST_OFFLINE_LOG
trap - 0
}
umask 027
touch $WLST_OFFLINE_LOG
chmod 777 $WLST_OFFLINE_LOG
if [ ! -d $WLST_CACHEDIR ] ; then
mdkir -p $WLST_CACHEDIR
fi
trap killed 0 1 2 15
# set up common environment
. "${WL_HOME}/server/bin/setWLSEnv.sh" 2>&1 > /dev/null
CLASSPATH="${CLASSPATH}${CLASSPATHSEP}${FMWLAUNCH_CLASSPATH}${CLASSPATHSEP}${DERBY_CLASSPATH}${CLASSPATHSEP}${DERBY_TOOLS}${CLASSPATHSEP}${POINTBASE_CLASSPATH}${CLASSPATHSEP}${POINTBASE_TOOLS}:${FKUTILS}"
#echo CLASSPATH=${CLASSPATH}
JVM_ARGS="-classpath ${JYTHON}/jython.jar:${CLASSPATH} -Dpython.path=${CLASSPATH}:${HOME} ${WLST_PROPERTIES} ${JVM_D64} ${MEM_ARGS} ${CONFIG_JVM_ARGS} -Dpython.cachedir=$WLST_CACHEDIR -Dwlst.offline.log=$WLST_OFFLINE_LOG -Dweblogic.management.confirmKeyfileCreation=true -Djava.security.egd=file:///dev/urandom"
eval '"${JAVA_HOME}/bin/java"' ${JVM_ARGS} org.python.util.jython '"[email protected]"'
而且作爲一種變通方法,你必須修改從writeInitfile的WLST文件,(你可能仍然得到一個堆棧跟蹤,但它會工作)
from weblogic.management.scripting.utils import WLSTUtil
import sys
origPrompt = sys.ps1
# Workaround start..
try:
theInterpreter = WLSTUtil.ensureInterpreter()
except:
pass
theInterpreter = WLSTUtil.ensureInterpreter()
# End workaround.
WLSTUtil.ensureWLCtx(theInterpreter)
execfile(WLSTUtil.getWLSTScriptPath())
execfile(WLSTUtil.getOfflineWLSTScriptPath())
exec(WLSTUtil.getOfflineWLSTScriptForModule())
execfile(WLSTUtil.getWLSTCommonModulePath())
theInterpreter = None
sys.ps1 = origPrompt
modules = WLSTUtil.getWLSTModules()
for mods in modules:
execfile(mods.getAbsolutePath())
wlstPrompt = "false"
後,你可以只啓動Jython的第一個腳本
,並導入WLST文件。
例:
Jython 2.7a2 (default:9c148a2, May 24 2012, 15:49:00) [Java
HotSpot(TM) 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_34
Type "help", "copyright", "credits" or "license" for more information.
>>> import fkwl as wl
>>> wl.connect('user','password','t3://server')
Connecting to t3://server with userid user ...