Java EEアプリケーションで、このコードをプロパティファイルを読み込むために使用しています。 Myservice.properties
がWEB-INF/classes
フォルダの下に置かれていても、プロパティはLinux環境では読み込まれませんが、Windows環境で正常に動作しています。InputStreamReader getResourceAsStreamはLinuxで動作しますか?
InputStreamReader fMainProp = new InputStreamReader(this.getClass().getResourceAsStream("/Myservice.properties"));
上記はWindowsでのみ有効ですか? getClass()
で表されるように、あなたのコード内で呼び出し元のクラスをロードしたクラスローダが/WEB-INF/classes
へのアクセス権を持っている場合、そのコードが動作するかどうか
MyWeb() {
prop = new Properties();
try {
InputStreamReader fMainProp = new InputStreamReader(this.getClass().getResourceAsStream("/Myservice.properties"));
prop.load(fMainProp);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
Linuxではどうなりますか? 'getResourceAsStream()'は 'null'を返しますか? –