Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am very new to spring . I am trying basic example . I got the following error

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [C:\Users\Raghavendra\workspace\SpringDraw\spring.xml]; nested exception is java.io.FileNotFoundException: spring.xml (The system cannot find the file specified)

I think this error from XML file ,
I think i made a mistake in DOCTYPE definition can you please help me in this . and jars I used here are

org.springframework.core-3.0.1.RELEASE-A
com.springsource.org.apache.commons.logging-1.1.1
org.springframework.beans-3.0.1.RELEASE-A
Posted
Comments
Maarten Kools 21-Feb-14 7:41am    
Well, as the exception is a FileNotFoundException, I'd say the file doesn't exist at the specified path.
Raghavendra M 21-Feb-14 7:43am    
No . , file is there . . but i didnt specify path any where . . If that is so where should i specify file path
Maarten Kools 21-Feb-14 7:45am    
If the file is there, then perhaps it's a permission issue. You might not have permission to read the file at that location when running your program?
Raghavendra M 21-Feb-14 7:48am    
Hey I have solved this .., see at first used
BeanFactory factory=new XmlBeanFactory(new FileSystemResource("spring.xml"));

it gives error but now I used
Resource resource=new ClassPathResource("spring.xml");
BeanFactory factory=new XmlBeanFactory(resource);

its solve now . . , what is the difference in that.
Maarten Kools 21-Feb-14 7:51am    
Well, I'm not too familiar with Spring/Java, but I can take a guess. A FileSystemResource would be a file on disk, in the working folder of the application. A ClassPathResource would be a file that is located in a folder that is declared in the class path.

1 solution

Answered to remove it from the unanswered questions queue.

As found by Raghavendra M:
Hey I have solved this .., see at first used
Java
BeanFactory factory=new XmlBeanFactory(new FileSystemResource("spring.xml"));


it gives error but now I used
Java
Resource resource=new ClassPathResource("spring.xml");
BeanFactory factory=new XmlBeanFactory(resource);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900