Skip to content

Regression about the suppport of the tag <import resource="..."/> [SPR-6494] #11160

Closed
@spring-projects-issues

Description

@spring-projects-issues

Bertrand Fovez opened SPR-6494 and commented

The tag <import resource="..."/> acts differently in version 3.0.0 and 2.5.6.
For example, consider these two xml configuration files, located in a package "context".

File: dependent-context.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="myBean" class="java.lang.String" />
</beans>

File: super-context.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<import resource="dependent-context.xml" />
</beans>

We load the latter, using the following:
new ClassPathXmlApplicationContext("context/super-context.xml");

Here is the log using Spring 2.5.6.SEC01:


11:47:58,903 INFO [ClassPathXmlApplicationContext] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@19efb05: display name [org.springframework.context.support.ClassPathXmlApplicationContext@19efb05]; startup date [Wed Dec 02 11:47:58 CET 2009]; root of context hierarchy
11:47:58,949 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [context/super-context.xml]
11:47:59,027 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [context/dependent-context.xml]
11:47:59,059 INFO [ClassPathXmlApplicationContext] Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@19efb05]: org.springframework.beans.factory.support.DefaultListableBeanFactory@47393f
11:47:59,059 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@47393f: defining beans [myBean]; root of factory hierarchy

Note that the dependent-context.xml file is loaded as "class path resource [context/dependent-context.xml]"

Here is the log using Spring 3.0.0.RC3:


12:06:57,312 INFO [ClassPathXmlApplicationContext] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@8814e9: startup date [Wed Dec 02 12:06:57 CET 2009]; root of context hierarchy
12:06:57,608 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [context/super-context.xml]
12:06:57,686 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from URL [file:/C:/Workspace/__Test/target/classes/context/dependent-context.xml]
12:06:57,795 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1a9334: defining beans [myBean]; root of factory hierarchy

Note that the dependent-context.xml file is new loaded as "URL [file:/C:/Workspace/__Test/target/classes/context/dependent-context.xml]"

If the two file are located in different folders on the file system, as it is often the case, the loading fails.

This difference generates several major regressions in our existing projects.


Affects: 3.0 RC3

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions