I am using spring java based configuration in web app. I have an issue.
In my config file I am doing import and getting some other java config files.
When I run my test cases all the test cases are passing.In my test cases I am using Aplication to get the bean. I dont have any problem there. But When I tell it to run on server it is saying that one of the config es doesn't exist. So import is not working. But when I do ctrl+click on the code I am able to travel into that config code.
I am using TomCat Version 7.0 and Using maven I am getting all other dependencies.
Stack trace is as below:
INFO: Initializing Spring root WebApplication
Jul 18, 2012 4:56:28 PM org.apache.catalina.core.Standard Start
SEVERE: to of
org.springframework.web..Loader
org.springframework.beans.factory.BeanDefinitionStore: Failed to load bean :
com.Hello.World.HelloWorldConfig; nested is
java.io.FileNotFound: path resource [com/hello/configs/MyConfig.] cannot be opened because it does not exist
at org.springframework..annotation.ConfigurationPostProcessor.processConfigBeanDefinitions(ConfigurationPostProcessor.java:267)
at org.springframework..annotation.ConfigurationPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationPostProcessor.java:203)
at org.springframework..support.AbstractApplication.invokeBeanFactoryPostProcessors(AbstractApplication.java:622)
at org.springframework..support.AbstractApplication.refresh(AbstractApplication.java:451)
at org.springframework.web..Loader.configureAndRefreshWebApplication(Loader.java:385)
at org.springframework.web..Loader.initWebApplication(Loader.java:284)
at org.springframework.web..Loader.(Loader.java:111)
at org.apache.catalina.core.Standard.Start(Standard.java:4779)
at org.apache.catalina.core.Standard.startInternal(Standard.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.FileNotFound: path resource [com/hello/configs/MyConfig.] cannot be opened because it does not exist
at org.springframework.core.io.PathResource.getInputStream(PathResource.java:157)
at org.springframework.core.type.reading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49)
at org.springframework.core.type.reading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
at org.springframework.core.type.reading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)
at org.springframework.core.type.reading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)
at org.springframework..annotation.ConfigurationParser.processImport(ConfigurationParser.java:317)
at org.springframework..annotation.ConfigurationParser.doProcessConfiguration(ConfigurationParser.java:228)
at org.springframework..annotation.ConfigurationParser.processConfiguration(ConfigurationParser.java:149)
at org.springframework..annotation.ConfigurationParser.parse(ConfigurationParser.java:126)
at org.springframework..annotation.ConfigurationPostProcessor.processConfigBeanDefinitions(ConfigurationPostProcessor.java:263)
... 16 more
Jul 18, 2012 4:56:28 PM org.apache.catalina.core.Standard startInternal
SEVERE: Error Start
Jul 18, 2012 4:56:28 PM org.apache.catalina.core.Standard startInternal
SEVERE: [/helloWorld] startup failed due to previous errors
Jul 18, 2012 4:56:28 PM org.apache.catalina.core.Application log
INFO: Closing Spring root WebApplication
And the config as follows
@Configuration
@Import({MyConfig.})
public HelloWorldConfig {
@Autowired
public MyName myName;
@Bean
public MyModel myModel() {
MyModel bean = new MyModel();
bean.setMyName(myName);
return bean;
}
}
I am not able to figure out what I am missing.
UPDATE:
I noticed that when I close the MyName project in eclipse it is not working and when I open it project is working. But MyModel project should not depend on myname project on local disk. I created a jar for Myname project and pushed it into central repository. So it should get the jar from repo. So i am not able to get understand what it has to do with my local disk content.
Thanks