Javatpoint Logo

Spring Program throw file not exist even file exist. used full path also

By: mradul*** On: Mon Aug 31 14:59:09 IST 2015     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
Hi ,

I used spring sample program .
after downloaded given spcorejars.zip code compiled successfully.

http://www.javatpoint.com/example-of-spring-application-in-eclipse



but once i run call , i get error file not exist.
Please tell why this error occur and how to resolve. I also used complete path , but getting same error with whole path with file name.


======================================================

log4j:WARN No appenders could be found for logger (org.springframework.beans.factory.xml.XmlBeanDefinitionReader).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [my.xml]; nested exception is java.io.FileNotFoundException: class path resource [my.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.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at com.javatpoint.Test.main(Test.java:22)
Caused by: java.io.FileNotFoundException: class path resource [my.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)
... 4 more


==================================================
Up0Down

 
Hi ,
I had one question: Do we really need .springBeans file in our project?

I used your example firstspring project and its working fine . after comparison .
i found you added one .springBeans with below content.

<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[2.3.2.me201004140951]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>src/applicationContext.xml</config>
</configs>
<configSets>
</configSets>
<springVersion>3.0</springVersion>
</beansProjectDescription>

Image Created0Down

By: [email protected] On: Mon Aug 31 15:20:08 IST 2015 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
To resolve the problem:
log4j:WARN No appenders could be found for logger (org.springframework.beans.factory.xml.XmlBeanDefinitionReader).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource

Solution:
Steps :
1.Please make ensure that your file : applicationContext.xml should be present inside src folder and not in inside com.javatpoint package.
2.If it is present inside com.javatpoint package then remove from here.
3.Make applicationContext.xml inside src folder.
Image Created0Down

By: [email protected] On: Wed Nov 14 19:48:16 IST 2018 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No