• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

got an exception in configuration file

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 "/>"
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks mark,

i know thants work fine , why idref attribute is not working.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic