0

我正在处理一些遗留代码。尝试通过 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 的问题。如果事实证明是这样,我将修改我的问题。

4

1 回答 1

0

事实上,事实证明,答案是它是一个 32 位 DLL,而我试图用 64 位 Java 运行它。不是很直观的错误信息...

于 2012-07-30T18:56:32.777 回答