是的,您可以使用另一个 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 '"$@"'
作为一种解决方法,您必须从 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:9c148a201233, 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 ...