无法为Jython设置java.library.path

时间:2012-07-30 18:32:10

标签: jython unsatisfiedlinkerror

我正在处理一些遗留代码。试图通过Jython在我们的代码中运行python脚本,我得到一个UnsatisfiedLinkError。我试图使用“-D”选项来设置java.class.path选项,但它似乎无法解决问题。对于以下示例,Durandal.jar

下可以使用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;

我的理解是,当一个人试图访问不在类路径中的库时,通常会发生这个错误,但我想我已经在命令行上正确设置了它。再说一次,我对Jython还不是很熟悉(对Java或Python不太熟悉),所以我有点在海上。

编辑:看起来这可能是尝试在64位Java下运行32位DLL的问题。如果情况确实如此,我会修改我的问题。

1 个答案:

答案 0 :(得分:0)

事实上,答案是,它是一个32位DLL,我试图用64位Java运行它。不是非常直观的错误消息......