Mace
Mace

Reputation: 31

Jython ImportError: No module named * (only on Windows Server 2012)

I have a CreateDomain.py script for weblogic. And now I want to import a java class in the python script. I exported the class com.swisslog.python.util.FileNameUtil to a jar and added it to the class path before calling the python script.

Here's the start of the script:

from wlstModule import *
from java.io import FileInputStream
from java.util import Properties
import jarray.array
import os
import shutil
import traceback
import sys
import getopt
from com.swisslog.python.util import FileNameUtil

I start the script from a bat file:

set CLASSPATH=%CLASSPATH%;wm6-python-util.jar
%MW_HOME%\wlserver\common\bin\wlst.cmd common\CreateDomain.py %1 %2 %3 %4

This works on Windows 7. But on Windows Server 2012 I get following error:

ImportError: no module named swisslog

Also using the full path doesn't work (jython ImportError: No module named)

Any help would be appreciated.

Upvotes: 0

Views: 1054

Answers (1)

Mace
Mace

Reputation: 31

I found a stupid workaround. I added a main method which calls the real methods and prints the result with system.out.print. Then I can start the jar from the python script without an import:

    result = os.popen(['java', '-jar', 'python-util.jar', 'arg').read()

Upvotes: 1

Related Questions