cutie_smily
asked on
creating bean for BufferedWriter gets failed
I am trying to create bufferedWriter like as shown below in my cpring config file
<bean name="fileWriter" class="java.io.FileWriter" >
<constructor-arg index="0">
<value>/home/translator3.3 /src/resou rces/sampl edata/cign a/welcomec allrubric. txt</value >
</constructor-arg>
<constructor-arg index="1">
<value>false</value>
</constructor-arg>
</bean>
<bean name="bufferedWriter" class="java.io.BufferedWri ter">
<constructor-arg index="1">
<ref bean="fileWriter" />
</constructor-arg>
</bean>
I am havin error
Cannot resolve reference to bean 'bufferedWriter' while setting bean property 'writer'; nested exception is org.springframework.beans. factory.Be anCreation Exception: Error creating bean with name 'bufferedWriter' defined in file [/home/rchilka/c4ctranslat or3.3/src/ resources/ config/cig na/welcome callrubric .xml]: Cannot resolve reference to bean 'fileWriter' while setting constructor argument; nested exception is org.springframework.beans. factory.Be anCreation Exception: Error creating bean with name 'fileWriter' defined in file [/home//src/resources/conf ig/comecal l.xml]: Instantiation of bean failed; nested exception is org.springframework.beans. BeanInstan tiationExc eption: Could not instantiate bean class [java.io.FileWriter]: Constructor threw exception; nested exception is java.io.FileNotFoundExcept ion: /home/rchilka/c4ctranslato r3.3/src/r esources/s ampledata/ cigna/welc omecallrub ric.txt (No such file or directory)
Related cause: org.springframework.beans. factory.Un satisfiedD ependencyE xception: Error creating bean with name 'DocumentBuilderFactory' defined in file [/home/rchilka/c4ctranslat or3.3/src/ resources/ config/cig na/welcome callrubric .xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: Ambiguous factory method argument types - did you specify the correct bean references as factory method arguments?
Can anybody help in solving above?
<bean name="fileWriter" class="java.io.FileWriter"
<constructor-arg index="0">
<value>/home/translator3.3
</constructor-arg>
<constructor-arg index="1">
<value>false</value>
</constructor-arg>
</bean>
<bean name="bufferedWriter" class="java.io.BufferedWri
<constructor-arg index="1">
<ref bean="fileWriter" />
</constructor-arg>
</bean>
I am havin error
Cannot resolve reference to bean 'bufferedWriter' while setting bean property 'writer'; nested exception is org.springframework.beans.
Related cause: org.springframework.beans.
Can anybody help in solving above?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.