When coding a Jython script to use class notation and import an existing class I get the following error:

C:\scripts>"C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.bat" -lang jython -f "C:/scripts/class_test.py"
WASX7209I: Connected to process "server1" on node myNode01 using SOAP connector;  The type of process is: UnManagedProcess
*** Loading Class JVMModifier...
setJVMProperties.py loaded as a module
dir(): ['__doc__', '__file__', '__name__', 'classJVMProperties']
WASX7017E: Exception received while running file "C:/scripts/class_test.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<string>", line 2, in ?
TypeError: call of non-function (module 'classJVMProperties')

Reason:

After you’ve done “import X”, the name X refers to the namespace of the module X.py, not the class (or any other object) in that module. To access the class, use dot notation: For example: x = X.X()

The code I had used was as follows:

Error:

import classJVMProperties
myJVM = setJVMProperties()

Solution

import classJVMProperties
myJVM = classJVMProperties.setJVMProperties()
Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply