3

I have a few questions concerning WLST and Jython:

OS: Unix/Linux

Situation:
1) Unable to include wlst-file created by using writeIniFile automatically
2) using org.python.util.jython without caching message

Information:
1) wlst.py generated by using writeIniFile in an interactive java weblogic.WLST session
2) when starting jython using java org.python.util.jython the message sys-package-mgr: can't create package cache dir, '/opt/oracle/fmw/fmw11gR1PS2/wlserver_10.3/server/lib/weblogic.jar/cachedir/packages' is shown
3) location for often used modules is unkown. For weblogic.WLST this is <WL-Home>/wlserver_10.3/common/wlst/modules

Questions:
1) where should common modules be placed for the included jython?
2) how to change jython cache location?
3) is it possible to update to another jython version?

Any and all help welcome.

Viccari
  • 9,029
  • 4
  • 43
  • 77
ShadowFlame
  • 2,996
  • 5
  • 26
  • 40

2 Answers2

4

Yes, you can use another jython, but it is not supported and there are some deffects you have to live with. We use jython 2.7a2.

Here is a script that we use to start jyton. It will change the cache location and add the FKUTILS directory to the classpath (It's where we store our own modules)

#!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 '"$@"'

And as a workaround you have to modify the wlst-file from writeInitfile, ( and you may still get a stacktrace, but it will work)

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"

after that you can just start jython the first script, and import your wlst-file.

Ex:

 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 ...
1

1) where should common modules be placed for the included jython? You can place the common modules, I have not tested it but if it is in the classpath it must pick the new packages for the jython.

2) how to change jython cache location? The temp directory must be accessible to all users. Check the permissions imposed for the /var/ or /tmp where WLSTTemp folder makes the package caching for reference Caching issue fix

3) is it possible to update to another jython version? It could be extensible with jython, WLST includes jython.jar. To use all other jython modules you should install jython and point your sys.path to the jython installation directory. Hints are available in the discussion thread

Community
  • 1
  • 1
PavanDevarakonda
  • 625
  • 5
  • 27