I am building a Spring application (which is a singleton application running on Geronimo server , not a web service or MVC application). On its load, I am trying to access a internal application context (which would manage a set of prototype beans - basically trying to manage all prototype beans using a hierarchical application context for clean shutdown of these beans).
I looked at various approaches as below:
Basically creating a secondary servlet (does not look like the best option to me) and accessing them
Or using a GenericWebApplicationContext (also tried all other WebApplicationContext related APIs) as below:
GenericWebApplicationContext context = new GenericWebApplicationContext(servletContext);
context.setParent(rootApplicationContext);
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(context);
xmlReader.loadBeanDefinitions(new ClassPathResource("ApplicationContext/beans.xml"));
context.refresh();
Please comment on the approaches. Is there any suggested approach ?
n addition, I also got the following error:
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)
Thanks