IBM Support

Adding Jython modules to the classpath

Technote (troubleshooting)


A Jython script, with an import command, works only if you have the respective module in the same directory.


In this command, -f /scirpts/jython/, the file contains the following line:

import common

The term "common" is nothing but a sample Jython script called

The only way to get this to work is to run the wsadmin command from the exact directory that exists in. Otherwise, it fails with the following exception:

WASX7209I: Connected to process "dmgr" on node manager using SOAP connector;  The type of process is: DeploymentManager                

WASX7017E: Exception received while running file "/scripts/61/jython/";
exception information: exception from Jython:
Traceback (innermost last): File "<string>", line 26, in ?
ImportError: no module named common


During the "import" operation, Jython is searching for the files only in the path, which are registered with its own registry (by default, working directory (./) will get registered). If you need to include your own custom files or modules, then the path of custom files should be registered with Jython. At the time of loading, this can be done through the System property python.path as key, and the custom file path as value.

Resolving the problem

For example, if you have 2 Jython files for import,

  • is in the profile_root/profile_name directory
  • is in the profile_root/ directory

Then run the wsadmin command like this, -lang jython  -javaoption
"-Dpython.path= <profile_root / profile_name >: < profile_root> "

When Jython is loaded, it will append the paths in the property python.path to its registry, and during execution, it searches for the files in the paths that are registered in its registry.

Document information

More support for: WebSphere Application Server
Administrative Scripting Tools (for example: wsadmin or ANT)

Software version: 7.0, 8.0, 8.5.5, 9.0

Operating system(s): AIX, HP-UX, Linux, Solaris, Windows

Software edition: Base, Network Deployment

Reference #: 1268538

Modified date: 23 August 2007

Translate this page: