I am executing a console application that is configured using Spring 3.0 JavaConfig annoation (see code below). When I run the application within Eclipse, I get the error below. The problem is that the xml file is not being found. It is in fact in that exact location with the web directory being in the root of the project. The xml file only had the header info. I have commented out all other elements. I have tried using an absolute path, every combination of path formatting I can think of, and relocating the xml file, all with the same results. If I comment out the @ImportResource line of code, the application works perfectly.
Any suggestions (I've also read the reference docs and Googled by fingers off with no luck)?
Code:
public class BiddingConsole{
public static void main(String[] args) throws BiddingException {
logger.debug("app started");
ApplicationContext ctx = new AnnotationConfigApplicationContext(LiquidlogicConfig.class);
// .... rest of my code
}
Code:
@Configuration
@ImportResource("classpath:web/WEB-INF/liquidlogic-config.xml")
public class LiquidlogicConfig {
//.... my code
}
Code:
03:15:36,194 INFO XmlBeanDefinitionReader (XmlBeanDefinitionReader.java:315) - loadBeanDefinitionsLoading XML bean definitions from class path resource [web/WEB-INF/liquidlogic-config.xml]
03:15:36,195 INFO DefaultSingletonBeanRegistry (DefaultSingletonBeanRegistry.java:421) - destroySingletonsDestroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1630ab9: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,liquidlogicConfig,biddingService,applicationService,stateFactory,applicationFactory,bidFactory,application]; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [web/WEB-INF/liquidlogic-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [web/WEB-INF/liquidlogic-config.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:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:233)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:99)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:84)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:187)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:146)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:624)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:614)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:398)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:65)
at com.liquidnetworks.liquidlogic.application.BiddingConsole.main(BiddingConsole.java:62)
Caused by: java.io.FileNotFoundException: class path resource [web/WEB-INF/liquidlogic-config.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
liquidlogic-config.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">