In a cofiguration file i am specifying a bean and its constructor. but i am getting FILE NOT FOUND EXCEPTION

<bean name="FileReader" class="">
            <constructor-arg index="0">

I am having 'File not found error". Could anyone suggest me where i went wrong
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can verify whether the file exists in the location  c:/rad/translator/src/resources/sampledata/member.lst mentioned in your configuration file. Btw, is it member.lst or txt? Also you can escape character to the file pah C:\\rad\\...
i've tested it and it worked properly.
i used this applicationContext.xml.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

      <bean name="FileReader" class="">
            <constructor-arg index="0">


this is the output:

when i changed the path to the file to a non-existing file i got this Exception:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FileReader' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class []: Constructor threw exception; nested exception is c:\temp\testx.txt

below is the code of my testapp
import org.springframework.context.ApplicationContext;
public class Test {
	 * @param args
	 * @throws IOException 
	public static void main(String[] args) throws IOException {
		ApplicationContext appCtx=new ClassPathXmlApplicationContext("applicationContext.xml");
		FileReader reader=(FileReader)appCtx.getBean("FileReader");

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Your application is working as epected. When a file reader cannot find a file, it throws an Exception. And if the file is present it reads and processes it properly. There is no problem that I could see in your code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.