Search code examples
javawebspherejython

How do I import AdminControl in WebSphere's jython?


When running websphere's Jython I'm not able to call the AdminControl command

Jython 2.1 on java1.6.0 (JIT: j9jit26)
Type "copyright", "credits" or "license" for more information.
>>> cellName = AdminControl.getCell()
Traceback (innermost last):
  File "<console>", line 1, in ?
NameError: AdminControl

I haven't seen anything from IBM or elsewhere that indicates AdminControl needs to be imported so I'm not sure why the above doesn't work.

Notes
WebSphere 8.5
I'm running jython with the command:

"$WAS_8_5_HOME"/java/jre/bin/java.exe -jar "$WAS_8_5_HOME"/optionalLibraries/jython/jython.jar

Solution

  • You can't. The AdminControl object is backed by an internal type, and it is registered by wsadmin when it starts. The only way to use it is via wsadmin -lang jython (possibly with -f script.py).