以下は私のディレクトリ構造です
/app/infra/myjar/bin --> contains my runnable jar
/app/infra/myjar/config --> contains all external config files which I want to read from code which is inside jar.
以下は、外部スプリング構成ファイルを読み取るための私のコードです
ApplicationContext basicConfig = new ClassPathXmlApplicationContext("classpath:/spring-bean-mapping.xml");
私のMANIFESTファイルには次のエントリがあります。
Class-Path:
.
../config/
また、/app/infra/myjar/config フォルダーを指すように .bashrc の CLASSPATH 変数を設定しました
を使用してjarを実行しようとしているとき
java -jar myjar.jar
次の例外が発生しています
Loading Spring Bean Mapping file
log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring-bean-mapping.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring-bean-mapping.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.vzw.esper.alerts.consumer.EsperMessagesConsumer.main(EsperMessagesConsumer.java:47)
Caused by: java.io.FileNotFoundException: class path resource [spring-bean-mapping.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 13 more
Exception in thread "main" java.lang.NullPointerException
at com.vzw.esper.alerts.consumer.EsperMessagesConsumer.main(EsperMessagesConsumer.java:86)
ここで何がうまくいかないのか、どうすれば理解できますか?