I am not sure whether this is the right section for my question because I am not sure what is happening.
I have a project using Spring that gives some very confusing output. When I run the project in NetBeans with Maven it outputs
Which sound like it has read and understood my bean definitions in spring-config.xml.
The next line then has me somewhat confused
Suddenly it cannot find spring-config.xml, but it has just read the file without problems.
Looking at the complete stacktrace indicates that it is the second of these two lines that cause the exception, and I suspect that it is the first the loads the file without problems.
Which sound like it has read and understood my bean definitions in spring-config.xml.
No.. Spring is just telling you that, it is trying to load the xml bean definitions from the file, which you have specified as it's present in classpath..
In the next line, it tells you that it can't read the file, because its not present..
Nothing confusing here, its pretty straight forward..
Where you have placed your spring-config.xml file... ?
The spring-config.xml has been placed by NetBeans in the folder containing the source of main package. It's in the folder src/main/java/dk/evorg/game under the project folder.
then you should be giving new ClassPathResource("dk/evorg/game/spring-config.xml"); If you just give spring-config.xml, it expects to be in the default package.
The same file in the default package works just fine. It just might stay in the default folder because it makes sense to me that a configuration file is located in src/main/resources.
Philip Grove wrote:The same file in the default package works just fine. It just might stay in the default folder because it makes sense to me that a configuration file is located in src/main/resources.
Yes, I agree it makes more sense. I always put my config files in the root of the classpath, and maven copies anything in the resources directory to the classpath.
INFO - Loading XML bean definitions from class path resource [carDemo-beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [carDemo-beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [carDemo-beans.xml] cannot be opened because it does not exist.
I see the above message in console. But I have initially created carDemo-beans.xml, placed in the package com/vehicles. Since I ws getting the above msg I have added the beans xml file to class path
by using add to build path option. After doing this, xml file was present at the referenced libraries section. Still I get the same error.
Regards
Larsen
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.