Incomplete Jython Libraries in WebSphere 6.0
WebSphere 6.0 ships with a very basic set of Jython libraries, which limits your ability to write robust scripts. WebSphere 6.1 however comes with the complete Jython 2.1 libraries.
If you need the ability to use standard Jython libraries in WebSphere 6.0 and are unable to immediately upgrade to 6.1 there is a work-around. This hack is not supported by IBM, so proceed at your own risk:
- Copy the Jython libraries from a WebSphere 6.1 instance (you can download a trial copy from IBM if you don’t have it). <WAS_HOME>/optionalLibraries/jython/*
- Drop the copied files into the same directory on your WebSphere 6.0 instance, overwriting all pre-existing files.
Using the above hack has allowed me to use practically all of my WAS 6.1 scripts in WAS 6.0.
January 2nd, 2008 at 6:29 am
what do you mean with robust scripts? what doesn’t work in jython with was 6.0 instead of was 6.1?
January 2nd, 2008 at 11:56 am
I generally consider a script as being robust when it can execute under many different circumstances. When I find myself having to modify a script so that it will function in a different environment than it was originally developed in - I don’t consider it robust.
If you have very simple scripts that only interact with the WebSphere Administrative objects, you probably won’t have to worry much about robustness. It’s only when you try to complicate things by interacting with the OS or file system that you really need to concentrate on being robust.
An example would be a script intended to perform a deployment and also sends log messages to a file. If this script was robust, it would be able to perform file IO for the logging regardless of the operating system (whether it’s Windows, Unix or Linux). In WebSphere 6.1, you could import the
osandshutilstandard Jython modules to perform simple tasks such as copying or deleting a file, determining the current directory etc. In WebSphere 6.0, you wouldn’t be able to perform any of those tasks as those modules are simply not included. Without the complete set of Jython modules is like scripting with one hand tied behind your back. You are limited to only writing simple basic scripts.For a list of Jython modules and their functionality see the following link (be aware that the provided link is for a later version than is used in WebSphere, so not all of the packages are included in WebSphere 6.1 - but the majority are):
http://docs.python.org/lib/
January 7th, 2008 at 1:38 am
WS 6.0 delivers with a really old Jython Beta version and instead of using Jython/Python stuff which is not implemented in the old Jython version you have to use the Java API. With Java calls from Jython you’ll have compatibility and IBM support.
January 7th, 2008 at 4:10 pm
Good point Markus. You can do anything in Java. It makes sense that if you find your self limited by Jython (current version or otherwise), then you can do it in Java via your Jython scripts. It’s also not a bad idea for compatibility between your jacl and jython scripts. It allows you to write functionality in Java that you can include in either jacl or jython scripts. If you relied on Jython to perform that functionality, you would have to re-write it if you wanted to use it in a jacl script.