*
The moose likes Spring and the fly likes got an exception in configuration file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "got an exception in configuration file" Watch "got an exception in configuration file" New topic
Author

got an exception in configuration file

prasad chowdary
Greenhorn

Joined: Feb 18, 2012
Posts: 18
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: 18
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: 17249
    
    6

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: 18
thanks mark,

i know thants work fine , why idref attribute is not working.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: got an exception in configuration file
 
Similar Threads
collection getting appended on refresh of page
The matching wildcard is strict, but no declaration can be found for element 'context:annotation'
Spring / Hibernate / cxf problems connecting with oracle
spring wont inject the entitymanager
Getting Error in setting property values