4

ネイティブ ライブラリを使用する必要があるアプリケーションがあります。libfoo.so

私のコードは次のとおりです。

アクセサ.java:

public class Accessor {        
    static {
        String path = "/usr/lib/libfoo.so";
        System.load(path);
    }
    ...
}

war ファイルをスタンドアロンの tomcat サーバーにデプロイすると、これは問題なく動作します。

問題は、実行時に組み込みの tomcat サーバーを実行しようとしたときです。

grails run-app

UnsatisfiedLinkError が発生します。

Caused by UnsatisfiedLinkError: com.foo.bar.GFS_MALJNI.new_Accessor__SWIG_0(Ljava/lang/String;I)J
->>   39 | <init>    in com.foo.bar.Accessor 

興味深いことに、BuildConfig.groovyファイルを fork モードに変更しても機能します。

BuildConfig.groovy:

grails.project.fork = [
   run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
]

フォークモードで実行したくありません。

4

2 に答える 2

0

My guess is that the Accessor class is being loaded multiple times in different classloaders within the same JVM (assuming grails runs in the same JVM as the embedded Tomcat). Test this by adding debug statements to the static block.

于 2013-05-22T18:59:36.510 に答える