Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Imported Jython modules unable to access WebSphere Management objects

144 views
Skip to first unread message

Rommer

unread,
Jul 10, 2007, 4:42:04 PM7/10/07
to
I am trying to write some jython scripting modules that perform unique
tasks (uninstall.py, deploy.py, modifyJVMArgs.py, modifyDatasource.py,
etc... ), and import those modules as needed. This seems to be more of
an object oriented approach compared to adding each task as a function
in a monolithic script file. The problem is that none of the WebSphere
management objects (AdminConfig, AdminApp, AdminControl, AdminTask)
work in imported files jython files. As an example, I have two jython
script files:

#***** Main.py *********
print AdminApp.list()
import test
test.show()
#*************************

#***** test.py ***********
def show():
print AdminApp.list()
#**************************

When I execute the Main.py:
./wsadmin.sh -lang jython -f Main.py

The AdminApp.list() in Main.py displays a list of applications,
however I get "NameError: AdminApp" when test.show() is executed. Both
files try to do the same thing, however, the imported test.py fails
when trying to access the "AdminApp" management object. The only way I
have been able to get it to work is to pass the management objects as
parameters. There has to be a better way of doing this. Does anyone
know how to make the WebSphere management objects visible to imported
jython modules? When using JACL I don't experience this same
limitation.

Peter Bennett

unread,
Jul 11, 2007, 12:40:19 PM7/11/07
to
You could set up a properties file for running with Jython, perhaps give it
a name wsadminjy.properties and content, such as: -
com.ibm.ws.scripting.connectionType=SOAP
com.ibm.ws.scripting.port=8879

com.ibm.ws.scripting.host=localhost
com.ibm.ws.scripting.defaultLang=jython
com.ibm.ws.scripting.echoparams=true
com.ibm.ws.scripting.traceFile=/tmp/jythonScript.trace
com.ibm.ws.scripting.validationOutput=/tmp/jythonValidation
com.ibm.ws.scripting.profiles=<yourWASHome>/bin/securityProcs.jacl;<yourWASHome>/bin/LTPA_LDAPSecurityProcs.jacl;~/Main.py;~/test.py

Then, if you call wsadmin with that properties file, such as: -
wsadmin.sh -p ~/wsadminjy.properties
And you should got those two files loaded automatically.
Either that or you could set up a command alias that calls something like
wsadmin.sh -profile ~all.py
And have all the functions defined within that all.py file.

Peter Bennett
Distributed Systems Professional Services Ltd.

"Rommer" <phill0...@netscape.net> wrote in message
news:1184100124.1...@i38g2000prf.googlegroups.com...

0 new messages