Skip to content

ref local does not consider name attribute [SPR-413] #5143

Closed
@spring-projects-issues

Description

@spring-projects-issues

Andreas Senft opened SPR-413 and commented

I just found out that there is a difference on using <ref bean="..."> or <ref local="...">, when accessing beans within the same configuration file.

If the referenced bean has only a name attribute and no id attribute it can be referenced via ref bean, but not via ref local.

Failing Example:

<bean id="Root" class="test.Root">
<property name="foo">
<ref local="Foo"/> <!-- ref bean will work -->
</property>
</bean>
<bean name="Foo" class="test.Foo">
</bean>

org.springframework.beans.factory.BeanDefinitionStoreException: Line 35 in XML document from class path resource [test.xml] is invalid; nested exception is org.xml.sax.SAXParseException: An element with the identifier "Foo" must appear in the document.
org.xml.sax.SAXParseException: An element with the identifier "Foo" must appear in the document.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:127)
at test.SpringTest.main(SpringTest.java:29)


Affects: 1.1.1

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions