問題:Log4j FileNotFoundException - Java FileSystemのgetBooleanAttributes()メソッドはどのように動作しますか?
2つの異なるワークスペースで同じmavenプロジェクトをチェックアウトしました。日食に輸入。きれいにしました。それらを作りました。 Tomcatに公開されています。
サーバを起動している間に、1つのセットアップでlog4jパス(linuxのようなもの)を見つけることができます。別の正確なセットアップは、パスを見つけることができないと、次のエラーがスローされます:私はdevCom.properties
に/home/deployment/devcom/config/devCom_log4j.properties
の前でD:
を追加
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'log4jInitialization' defined in URL [jar:file:/D:/apache-tomcat-7.0.50-old/wtpwebapps/DevCom-War/WEB-INF/lib/DevCom-Remittance-1.1.0-SNAPSHOT.jar!/config/applicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: Log4j config file [/home/deployment/devcom/config/devCom_log4j.properties] not found
場合にのみ、他のセットアップは、パスを認識し、エラーをスローしません。
Why the first setup is able to recognise and use the linux like path and the second setup does not?
Out of all the involved entities, where the problem might lie? Eclipse,Maven,Tomcat,SVN Eclipse Plugin ...?
EclipseでTomcatの設定:(使用Tomcatのインストール)
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -Xms712m -Xmx712m -XX:PermSize=256m -XX:MaxPermSize=356m -Dcatalina.base="D:\apache-tomcat-7.0.50-old" -Dcatalina.home="D:\apache-tomcat-7.0.50-old" -Dwtp.deploy="D:\apache-tomcat-7.0.50-old\wtpwebapps" -Djava.endorsed.dirs="D:\apache-tomcat-7.0.50-old\endorsed" -Dext.prop.dir="D:\home\deployment" -Denv.prop="dev"
春コンフィグ:
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:///${ext.prop.dir}/devcom/config/devCom.properties</value>
</property>
<property name="ignoreUnresolvablePlaceholders">
<value>true</value>
</property>
</bean>
<bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.springframework.util.Log4jConfigurer"/>
<property name="targetMethod" value="initLogging"/>
<property name="arguments">
<list>
<value>${log4j.config.location}</value>
<value>${log4j.refresh.interval}</value>
</list>
</property>
</bean>
D:\ホーム\展開\ devcom \ CONFIG \ devCom.properties:
log4j.config.location = /home/deployment/devcom/config/devCom_log4j.properties
(パスのようにLinuxを注意してください。)
log4j.refresh.interval = 100000
プロジェクト詳細:
のWindows 10
JDK 8
春3.0.5
のTomcat 7つの
Mavenの
エクリプス火星
Log4jConfigurer initLogging:
public static void initLogging(String location, long refreshInterval) throws FileNotFoundException {
String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location);
File file = ResourceUtils.getFile(resolvedLocation);
if (!file.exists()) {
throw new FileNotFoundException("Log4j config file [" + resolvedLocation + "] not found");
}
}
ファイル(存在):
public boolean exists() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
}
if (isInvalid()) {
return false;
}
return ((fs.getBooleanAttributes(this) & FileSystem.BA_EXISTS) != 0);
// first setup -> 3 & 1. second setup -> 0 & 1 !!! What does it mean? How does it work?
}
最後にgetBooleanAttributes
メソッドはどのように機能しますか?この問題の原因を絞り込むことは役に立ちますか?
ありがとうございました。
は、私はこの問題は、構成設定の違い可能性が知っていたが、推測することができませんでしたそれがどこにあるかもしれない。最後にそれを絞り込んだ。 'Tomcat - >オープン起動設定 - >引数 - >作業ディレクトリ(デフォルト)'最初のセットアップ: 'D:\ eclipse'セカンドセットアップ:' C:\ WINDOWS \ system32'。 1)この作業ディレクトリの使用は何ですか? 2)なぜtomcatのデフォルトが 'C:'ドライブに変更されたのですか? – user104309