| Author |
got an exception in configuration file
|
prasad chowdary
Greenhorn
Joined: Feb 18, 2012
Posts: 17
|
|
hello experts,
i am trying to inject objects through idref tag i got an exception
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="std" class="info.spring.test.Student">
<property name="name" value="sachin"></property>
<property name="roll_No" value="99"></property>
<property name="address1" ref="addr1"></property>
<property name="address2" >
<idref="addr2"/>
</property>
</bean>
<bean id="addr2" class="info.spring.test.Address" name="addr2_alias">
<property name="city" value="hyd"></property>
<property name="state" value="ap"></property>
</bean>
<bean id="addr1" class="info.spring.test.Address">
<property name="city" value="banglr"></property>
<property name="state" value="karnataka"></property>
</bean>
</beans>
Exception
Element type "idref" must be followed by either attribute specifications, ">" or "/>"
|
 |
Tapan Maru
Ranch Hand
Joined: May 08, 2006
Posts: 65
|
|
<idref bean="addr2"/>
Try out with the above code. Please share the resulets.
Thanks
|
Tapan Maru
tapanmaru@gmail.com
|
 |
prasad chowdary
Greenhorn
Joined: Feb 18, 2012
Posts: 17
|
|
Thanks Maru,
now, i got a new exception
Exception:
Failed to convert property value of type 'java.lang.String' to required type 'info.spring.test.Address' for property 'address2'; nested exception is java.lang.IllegalStateException:
|
 |
Mark Spritzler
ranger
Sheriff
Joined: Feb 05, 2001
Posts: 17225
|
posted

0
|
Why do you even want to use idref?
Why not just
<property name="address2" ref="add22"/>
or
Thanks
Mark">
|
Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
|
 |
prasad chowdary
Greenhorn
Joined: Feb 18, 2012
Posts: 17
|
|
thanks mark,
i know thants work fine , why idref attribute is not working.
|
 |
Mark Spritzler
ranger
Sheriff
Joined: Feb 05, 2001
Posts: 17225
|
posted

0
|
prasad chowdary wrote:thanks mark,
i know thants work fine , why idref attribute is not working.
Maybe because it is really old and people don't use it anymore?
Mark
|
 |
 |
|
|
subject: got an exception in configuration file
|
|
|