【发布时间】:2013-12-13 09:06:02
【问题描述】:
我正在构建一个 Spring 应用程序(它是在 Geronimo 服务器上运行的单例应用程序,而不是 Web 服务或 MVC 应用程序)。在加载时,我试图访问一个内部应用程序上下文(它将管理一组原型 bean - 基本上是尝试使用分层应用程序上下文管理所有原型 bean 以彻底关闭这些 bean)。
我研究了以下各种方法:
基本上创建一个辅助 servlet(对我来说似乎不是最好的选择)并访问它们
或使用 GenericWebApplicationContext(也尝试了所有其他与 WebApplicationContext 相关的 API),如下所示:
GenericWebApplicationContext context = new GenericWebApplicationContext(servletContext);
context.setParent(rootApplicationContext);
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(context);
xmlReader.loadBeanDefinitions(new ClassPathResource("ApplicationContext/beans.xml"));
context.refresh();
请评论这些方法。有什么建议的方法吗?
n 另外,我还收到如下错误:
2013-12-13 00:44:04,877 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ZKWatcherImpl' defined in URL [bundleresource://382.fwk1189431013/com/ebay/traffic/email/aggregate/watcher/ZKWatcherImpl.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.ebay.traffic.email.aggregate.watcher.ZKWatcherImpl]: Constructor threw exception;
nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context] Offending resource: class path resource [CustomContext.xml]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
谢谢
【问题讨论】:
-
人们也希望看到您的 CustomConetxt.xml