Search code examples
jythonunsatisfiedlinkerror

Having trouble setting java.library.path for Jython


I'm working with some legacy code at work. Trying to run on of the python scripts in our code via Jython, I'm getting an UnsatisfiedLinkError. I've tried to use the "-D" option to set the java.class.path option, but it doesn't seem to resolve things. For the following example, Durandal.jar is available under C:\scm\main\core\isidurandal\durandal\build

"C:\Program Files\Java\jdk1.6.0_31\bin\java.exe" -Xint "-Dpython.path=c:\scm\main\core\isidurandal\durandal\scripts\lib" "-Dpython.home=c:\bin\jython2.5.2" "-Djava.library.path=c:\scm\main\core\isidurandal\durandal\build" -classpath "c:\bin\jython2.5.2\jython.jar;c:\scm\main\core\isidurandal\durandal\build\durandal.jar;c:\scm\main\core\isidurandal\japanese\build\durandalJapanese.jar;c:\scm\main\core\isidurandal\biometrics\build\MtiBiometrics.jar" org.python.util.jython  tools\alignSequences.py

=========================================================
Monolithic library init failed with UnsatisfiedLinkError:
java.lang.UnsatisfiedLinkError: no durandal in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1028)
        at com.interactivesys.durandal.base.Library.<clinit>(Unknown Source)
        at com.interactivesys.durandal.recognition.Library.<clinit>(Unknown Sour
ce)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at org.python.core.Py.loadAndInitClass(Py.java:895)
        at org.python.core.Py.findClassInternal(Py.java:830)
        at org.python.core.Py.findClassEx(Py.java:881)
        at org.python.core.packagecache.SysPackageManager.findClass(SysPackageMa
nager.java:133)
        at org.python.core.packagecache.PackageManager.findClass(PackageManager.
java:28)
        at org.python.core.packagecache.SysPackageManager.findClass(SysPackageMa
nager.java:122)
        at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)

        at org.python.core.PyObject.__findattr__(PyObject.java:863)
        at org.python.core.imp.import_name(imp.java:849)
        at org.python.core.imp.importName(imp.java:884)
        at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
        at org.python.core.PyObject.__call__(PyObject.java:357)
        at org.python.core.__builtin__.__import__(__builtin__.java:1173)
        at org.python.core.imp.importFromAs(imp.java:978)
        at org.python.core.imp.importFrom(imp.java:954)
        at org.python.pycode._pyx0.f$0(tools\alignSequences.py:18)
        at org.python.pycode._pyx0.call_function(tools\alignSequences.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1261)
        at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:235
)
        at org.python.util.jython.run(jython.java:247)
        at org.python.util.jython.main(jython.java:129)
Traceback (most recent call last):
  File "tools\alignSequences.py", line 1, in <module>
    from com.interactivesys.durandal.recognition import Library
java.lang.UnsatisfiedLinkError: com.interactivesys.durandal.base.ResourceLocator
.resolvePath(Ljava/lang/String;)Ljava/lang/String;
        at com.interactivesys.durandal.base.ResourceLocator.resolvePath(Native M
ethod)
        at com.interactivesys.durandal.base.Library.<clinit>(Unknown Source)
        at com.interactivesys.durandal.recognition.Library.<clinit>(Unknown Sour
ce)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at org.python.core.Py.loadAndInitClass(Py.java:895)
        at org.python.core.Py.findClassInternal(Py.java:830)
        at org.python.core.Py.findClassEx(Py.java:881)
        at org.python.core.packagecache.SysPackageManager.findClass(SysPackageMa
nager.java:133)
        at org.python.core.packagecache.PackageManager.findClass(PackageManager.
java:28)
        at org.python.core.packagecache.SysPackageManager.findClass(SysPackageMa
nager.java:122)
        at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)

        at org.python.core.PyObject.__findattr__(PyObject.java:863)
        at org.python.core.imp.import_name(imp.java:849)
        at org.python.core.imp.importName(imp.java:884)
        at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
        at org.python.core.PyObject.__call__(PyObject.java:357)
        at org.python.core.__builtin__.__import__(__builtin__.java:1173)
        at org.python.core.imp.importFromAs(imp.java:978)
        at org.python.core.imp.importFrom(imp.java:954)
        at org.python.pycode._pyx0.f$0(tools\alignSequences.py:18)
        at org.python.pycode._pyx0.call_function(tools\alignSequences.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1261)
        at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:235
)
        at org.python.util.jython.run(jython.java:247)
        at org.python.util.jython.main(jython.java:129)

java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: com.interactives
ys.durandal.base.ResourceLocator.resolvePath(Ljava/lang/String;)Ljava/lang/Strin
g;

My understanding is that this error generally happens when one tries to access a library which is not in the class path, but I think I've set it correctly on the command line. Then again, I'm also not yet very familiar with Jython (not horribly familiar with Java or Python), so I'm somewhat at sea.

Edit: It looks like this might be an issue with trying to run a 32-bit DLL under 64-bit Java. I will revise my question if that turns out to be the case.


Solution

  • Indeed, the answer, as it turns out, is that it was a 32-bit DLL and I was trying to run it with the 64-bit Java. Not very intuitive error messages...