Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

got an exception in configuration file

 
prasad chowdary
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<idref bean="addr2"/>

Try out with the above code. Please share the resulets.

Thanks
 
prasad chowdary
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you even want to use idref?

Why not just

<property name="address2" ref="add22"/>

or



Thanks

Mark">
 
prasad chowdary
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks mark,

i know thants work fine , why idref attribute is not working.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic