WebSphere wsadmin scripting - Import os module error for versionbelow 6.1 - Websphere

This is a discussion on WebSphere wsadmin scripting - Import os module error for versionbelow 6.1 - Websphere ; Hi, I have done Websphere deployment automation using Jython in was 6.1 version. I am trying to use the same to get those working for 5.1.3 and 6.0.23 but i had some issues for a module a below: In my ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: WebSphere wsadmin scripting - Import os module error for versionbelow 6.1

  1. WebSphere wsadmin scripting - Import os module error for versionbelow 6.1

    Hi,



    I have done Websphere deployment automation using Jython in was 6.1 version. I am trying to use the same to get those working for 5.1.3 and 6.0.23 but i had some issues for a module a below:



    In my Jython script i am trying to import os module and use it for my coding purpose. When i do os.remove i get the below exception saying that the javaos module ImportError. Looks like that module do not exists below 6.1 version of websphere BSF framework for Jython.



    import os

    os.remove(.....)



    wsadmin>import os

    wsadmin>os.remove("E:\san\EARDeploymentProject\AppName.txt")

    WASX7015E: Exception running command: "os.remove("E:\san\EARDeploymentProject\AppName.txt")"; exception information:

    com.ibm.bsf.BSFException: exception from Jython: Traceback (innermost last):

    File "<input>", line 1, in ?

    ImportError: no module named javaos



    How do i get around with it...i belive i can get the jython os module imported into websphere 5.x and 6.0.x...does any one has any idea on how we can fix this situation.



    Thank you.

  2. Re: WebSphere wsadmin scripting - Import os module error forversion below

    Found the solution if any one cares....



    1. WebSphere v6.1 execution and debugging

    Because WebSphere v6.1 now includes the complete Jython Lib within <WASROOT>\optionalLibraries\jython, the converted wsadmin Jython scripts have full access to all the Jython library functions. And, because the debugging module pdb.py is in that Lib, the v6.1 Application Server Toolkit (AST) Jython Debugger can debug wsadmin Jython programs using a local WebSphere v6.1 installation, and this is fully supported.



    2. WebSphere v5.1 or v6.0 execution

    Older WebSphere v5.1 and v6.0 only included the core jython.jar and did not reship the Jython library Lib directory. If your Jacl2Jython converted wsadmin Jython program makes use of any of the above runtime library functions, and if you attempt to run that Jython script on an older WebSphere v5.1 or v6.0 installation, then you will need to manually add a Jython Lib directory to the same location as the WebSphere jython.jar (typically <WASROOT>\lib for version 5.1, <WASROOT>\optionalLibraries for v6.0.0.0, <WASROOT>\optionalLibraries\jython for v6.0.0.2 or later. For maximum compatibility the Jython Lib directory should be copied from a WebSphere v6.1 (which uses the same Jython v2.1.3 distribution). However, since this is not the way the older WebSphere product was shipped, such a change is officially unsupported.

+ Reply to Thread