1

別のバンドル ( " com.elsten.bliss.platform") を使用するバンドル (" net.contentobjects.jnotify") があります。net.contentobjects.jnotifyフラグメントによって提供されるネイティブ ライブラリをロードして、ジョブを実行します。net.contentobjects.jnotifyネイティブ コードは、バンドル内のクラス内の静的クラス初期化子に読み込まれます。

static
{
    System.loadLibrary("jnotify");
    int res = nativeInit();
    if (res != 0)
    {
        throw new RuntimeException("Error initializing fshook_inotify library. linux error code #" + res  + ", man errno for more info");
    }
    init();
}

起動と停止ができcom.elsten.bliss.platform、問題なく動作しているようです。更新時に問題が発生しcom.elsten.bliss.platformます。更新すると、次のようになります。

2013-04-04 11:58:20,356 [ERROR]  Couldn't initialise JNotify: java.lang.UnsatisfiedLinkError: Native Library /home/gravelld/eclipse-workspaces/bliss/net.contentobjects.jnotify.linux.amd64/lib/libjnotify.so already loaded in another classloader (JnotifyFileSystemObserver.java:53, thread platformExecutor)
java.lang.UnsatisfiedLinkError: Native Library /home/gravelld/eclipse-workspaces/bliss/net.contentobjects.jnotify.linux.amd64/lib/libjnotify.so already loaded in another classloader
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1715)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
    at java.lang.Runtime.loadLibrary0(Runtime.java:840)
    at java.lang.System.loadLibrary(System.java:1047)
    at net.contentobjects.jnotify.linux.JNotify_linux.<clinit>(JNotify_linux.java:48)
    at net.contentobjects.jnotify.linux.JNotifyAdapterLinux.<init>(JNotifyAdapterLinux.java:76)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at java.lang.Class.newInstance0(Class.java:374)
    at java.lang.Class.newInstance(Class.java:327)
    at net.contentobjects.jnotify.JNotify.<clinit>(JNotify.java:75)
    at com.elsten.bliss.platform.storage.file.JnotifyFileSystemObserver.startWatching(JnotifyFileSystemObserver.java:43)
    at com.elsten.bliss.platform.storage.file.NotifyFilesAtStartFileSystemObserver.start(NotifyFilesAtStartFileSystemObserver.java:117)
    at com.elsten.bliss.platform2.PlumbedStorageSubsystem.start(PlumbedStorageSubsystem.java:69)
    at com.elsten.bliss.client.impl.ConfigurationClientImpl$3.doRun(ConfigurationClientImpl.java:337)
    at com.elsten.util.CatchThrowableRunnable.run(CatchThrowableRunnable.java:23)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)

1 つのクラスローダでロードできるネイティブ ライブラリは 1 つだけです。しかし、この場合、なぜ複数のクラス・ローダーがあるのでしょうか? はnet.contentobjects.jnotify更新されていないので、既存のクラスはそのまま継続して使用する必要があると思いましたJnotifyFileSystemObserver.startWatching。このメソッドがクラスをリロードしているようです。

どうすればこれを回避できますか?

4

1 に答える 1

1

興味深いことに、そのコードは 2 回呼び出されても例外を発生させません。java.lang.Runtime#loadLibrary()状態のjavadoc

このメソッドが同じライブラリ名で複数回呼び出された場合、2 回目以降の呼び出しは無視されます。

だから、それ以上のものがあるかもしれません。MANIFEST.MF の Bundle-SymbolicName エントリで singleton プロパティを設定しようとしましたか?

于 2013-04-04T13:26:22.877 に答える