是的,您可以使用其他Jython版本,但这不受支持,并且您必须忍受一些缺陷。我们使用的是jython 2.7a2。
以下是我们用来启动jyton的脚本。
它将更改缓存位置并将FKUTILS目录添加到类路径中(这是我们存储自己模块的地方)
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
. "${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}"
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 '"$@"'
作为一种解决方法,你需要修改wlst文件来自writeInitfile函数处理(可能仍然会出现堆栈跟踪,但它可以正常工作)。
from weblogic.management.scripting.utils import WLSTUtil
import sys
origPrompt = sys.ps1
try:
theInterpreter = WLSTUtil.ensureInterpreter()
except:
pass
theInterpreter = WLSTUtil.ensureInterpreter()
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 ...