运行 OS X El Capitan 上的 IBM Notes Java 应用程序抛出 UnsatisfiedLinkError

Running an IBM Notes Java Application on OS X El Capitan throws UnsatisfiedLinkError

我正在尝试 运行 访问 Mac 上的 Notes 客户端的 HelloWord Java 应用程序。我在旧版本上工作。目前我有 Java 1.8.0_101-b13 和 OS/X 10.11.6。我尝试 运行 这个代码:

import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.NotesThread;
import lotus.domino.Session;

public class HelloWorld {

  public static void main(String[] args) throws NotesException {
    HelloWorld hw = new HelloWorld();
    hw.sayHello();
  }

  private void sayHello() throws NotesException {
    System.out.println("java.library.path: "+ System.getProperty("java.library.path"));
    System.out.println("PATH: "+ System.getenv("PATH"));
    NotesThread.sinitThread();
    Session s = NotesFactory.createSession();
    System.out.println(s.getEffectiveUserName());
    NotesThread.stermThread();
  }
} 

我在 Eclipse 运行 配置中设置了 LD_LIBRARY_PATH=/Applications/IBM Notes.app。当我 运行 我得到的应用程序时:

java.library.path: /Applications/IBM Notes.app:/Users/joe/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. PATH: /Applications/IBM Notes.app:/usr/bin:/bin:/usr/sbin:/sbin Exception in thread "main" java.lang.UnsatisfiedLinkError: no lsxbe in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at lotus.domino.NotesThread.load(Unknown Source) at lotus.domino.NotesThread.checkLoaded(Unknown Source) at lotus.domino.NotesThread.sinitThread(Unknown Source) at com.notessensei.HelloWorld.sayHello(HelloWorld.java:31) at com.notessensei.HelloWorld.main(HelloWorld.java:20)

库路径看起来没问题。我一定是遗漏了一些明显的东西?

Update:当您查看输出时,Java 选择了 LD_LIBRARY_PATH 变量,因此似乎不需要 DYLD_LIBRARY_PATH (我添加了它来测试无济于事)。 DYLD... 似乎 be problematic OS/X。

一个不太清楚的想法:在OS/X世界你通常指向应用程序(IBMNotes.app),但内容实际上在appname.app/Contents/MacOS。我想我都尝试了相同的结果。路径中的space会不会吐出来?

更新 2:根据要求 otool -L liblsxbe.dylib

的输出

liblsxbe.dylib: @executable_path/liblsxbe.dylib (compatibility version 0.0.0, current version 0.0.0) @executable_path/libxmlproc.dylib (compatibility version 0.0.0, current version 0.0.0) @executable_path/libnotes.dylib (compatibility version 0.0.0, current version 0.0.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 60.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

otool -L libxmlproc.dylib

libxmlproc.dylib: @executable_path/libxmlproc.dylib (compatibility version 0.0.0, current version 0.0.0) @executable_path/libnotes.dylib (compatibility version 0.0.0, current version 0.0.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 60.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

`otool -L libnotes.dylib'

libnotes.dylib: @executable_path/libnotes.dylib (compatibility version 0.0.0, current version 0.0.0) /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0) @executable_path/libjsmac.dylib (compatibility version 0.0.0, current version 0.0.0) @executable_path/libndgts.dylib (compatibility version 0.0.0, current version 0.0.0) @executable_path/libxmlproc.dylib (compatibility version 0.0.0, current version 0.0.0) @executable_path/libgsk8iccs.dylib (compatibility version 0.0.0, current version 0.0.0) /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 55471.14.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 60.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.14.0) /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1265.19.0) /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork (compatibility version 1.0.0, current version 673.2.1) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 59.0.0)

还有什么?

经过多方探索,发现有两个问题需要解决。第一个,在post by Mikkel Flint Heisterberg中描述。除了 DYLD_LIBRARY_PATH 之外,还需要设置另一个环境变量:NOTESBIN。两者都指向同一位置:

DYLD_LIBRARY_PATH=/Applications/IBM Notes.app/Contents/MacOS
NOTESBIN=/Applications/IBM Notes.app/Contents/MacOS

Eclipse 运行 配置中不需要引号或反斜杠。

第二个更棘手。出于方便,因为它之前工作,我创建了一个名为 'Notes9' 的新条目 "installed JVM's"。在那里我指向了 Oracle JVM8(是的,在 Mac 上注释是 运行ning Java8)and Notes.jar(和其他)在 Notes 程序目录的 jvm/lib/ext 中。

Mac 不喜欢那样(不再)。一旦我指向 "naked" JVM8 并添加 Notes.jar 作为外部 Jar 依赖项,一切都按预期开始工作。

我一直在为几乎相同的问题而苦苦挣扎。我按照你在回答的第一部分所做的那样做了,即将 Eclipse 中的环境变量设置为以下

DYLD_LIBRARY_PATH=/Applications/IBM Notes.app/Contents/MacOS
NOTESBIN=/Applications/IBM Notes.app/Contents/MacOS

我也在我的 .bashrc 文件中写道:

PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/myuser/bin:/Applications/IBM\ Notes.app/Contents/MacOS

在我的 .profile 中:

export DYLD_LIBRARY_PATH=/Applications/IBM\ Notes.app/Contents/MacOS
export PATH=$PATH

# Update bashrc 
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

我在尝试解决这个问题时一直在使用 Eclipse Mars,但似乎 PATH 和 java.library.path 都不正确。我受够了 Mars,决定下载 Oxygen。我不知道为什么,但是在我安装 Oxygen、将环境变量添加到 Eclipse 并使用 Java 1.8 之后,我能够通过您的示例获得我的有效用户名,并且相同的解决方案适用于更大的应用程序我们正在开发中。

我只是将此答案添加为对您的答案的补充。我很高兴在 SO 上找到了这个问题。谢谢。