我继承了一个 Struts 1 应用程序,该应用程序由大约八个单独的包组成,这些包全部编译到同一个应用程序中。我的任务是重写它的 ant 构建脚本。以前它是将所有配置文件分别复制到 /usr/local/tomcat/shared/classes 目录中,但是我们的运维团队要求我们简化操作,因此构建脚本只创建一个可以放入 tomcat 的 war 文件。
当我的 ConfigurationManager 类尝试加载其配置文件时出现错误。此文件 config.xml 目前正在被复制到 WEB-INF 中,然后才与应用程序的其余部分进行同步。因此,当我查看爆炸战争(ROOT)时,我确实发现/usr/local/tomcat/webapps/ROOT/WEB-INF/config.xml
. 以下是 ConfigurationManager 的相关部分:
private static final String BASE_CONFIG_FILE = "WEB-INF/config.xml";
private void loadConfigFiles() throws RCConfigurationException {
try {
log.error("classpath: " + System.getProperty("java.class.path"));
ConfigurationFactory factory = new ConfigurationFactory();
URL configURL = getClass().getResource(BASE_CONFIG_FILE);
factory.setConfigurationURL(configURL);
config = factory.getConfiguration();
} catch (ConfigurationException e) {
log.error("Exception loading configuration files.", e);
throw new RCConfigurationException("Exception loading configuration files", e);
}
}
log.error() 调用输出以下内容:
13:16:10,561 ERROR ConfigurationManager:75 - classpath: /usr/local/tomcat/bin/bootstrap.jar
我的 localhost.2013-01-29.log 显示:
SEVERE: Exception starting filter GlobalRootManager
java.lang.ExceptionInInitializerError
at com.rc.util.config.ConfigurationManager.getInstance(ConfigurationManager.java:66)
at com.rc.commonbusinesswebapp.servlet.filter.GlobalRootManager.init(GlobalRootManager.java:42)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NullPointerException
at org.apache.commons.configuration.ConfigurationFactory.setConfigurationURL(ConfigurationFactory.java:220)
at com.rc.util.config.ConfigurationManager.loadConfigFiles(ConfigurationManager.java:79)
at com.rc.util.config.ConfigurationManager.<init>(ConfigurationManager.java:55)
at com.rc.util.config.ConfigurationManager.<init>(ConfigurationManager.java:26)
at com.rc.util.config.ConfigurationManager$LazyHolder.<clinit>(ConfigurationManager.java:37)
... 29 more
我正在旋转我的轮子,所以我希望这里有人可以帮助我。谢谢。