LoginSignup
2
1

More than 5 years have passed since last update.

Tomcat7で`antiResourceLocking="true"`にしたらDLLの初期化で失敗⇒原因不明

Posted at

teratailで質問したんですが、回答が付かなかったので、とりあえずQiitaに残しておきます。

前提

Tomcat Managerから配備解除すると、jarファイルが残って失敗する場合があります。
その対応として、下記サイトを参考にconf/context.xmlを修正しました。
http://ameblo.jp/spring-beginner/entry-10435382344.html

conf/context.xml
<Context antiJARLocking ="true" antiResourceLocking="true" >

発生している問題・エラーメッセージ

DLLの呼び出しで、
「java.lang.NoClassDefFoundError: Could not initialize class CLibrary」というエラーが出ます。
DLLは下記サイトを参考にして呼び出しています。
http://d.hatena.ne.jp/maachang/20110110

public class HelloWorld {
    public interface CLibrary extends Library {
        CLibrary INSTANCE = (CLibrary) Native.loadLibrary(
        (Platform.isWindows() ? "msvcrt" : "c"), CLibrary.class);
        void printf(String format, Object... args);
    }

    public static void main(String[] args) {
        CLibrary.INSTANCE.printf("Hello, World\n");
        for (int i = 0; i < args.length; i++) {
            CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]);
        }
    }
}

原因の調査

検索してもエラーの原因が分からず、ひとまずサーバの状態を元に戻したら、DLLは動きました。
antiJARLockingはjarファイル用の設定なので、antiResourceLockingが原因だと考えられます。
で、antiResourceLockingをtrueにすると、DLLが動かなくなる原因が分かりません。

補足情報(言語/FW/ツール等のバージョンなど)

If true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur. If not specified, the default value is false.
antiJARLocking is a subset of antiResourceLocking and therefore, to prevent duplicate work and possible issues, only one of these attributes should be set to true at any one time.
Please note that setting this to true has some side effects, including the disabling of JSP reloading in a running server: see Bugzilla 37668.
Please note that setting this flag to true in applications that are outside the appBase for the Host (the webapps directory by default) will cause the application to be deleted on Tomcat shutdown. You probably don't want to do this, so think twice before setting antiResourceLocking=true on a webapp that's outside the appBase for its Host.

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1