Issue 1:
Stefan Podkowinski opened SPR-5762 and commented

I've written a custom resource loader that is supposed to handle protocol "hdfs://" and registered the loader with the XmlBeanDefinitionReader as follows:

XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);

reader.setResourceLoader(resourceLoader);

Within my application, resolving resources with the "hdfs://" prefix is working perfectly fine. So I was rather surprised to see the following import directive fail:

<beans>

<import resource="hdfs:///meta/schemes/common.xml"/>

</beans>

The following exception will occur:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [hdfs:///meta/schemes/common.xml]

Offending resource: file [/home/test/workspace/test/application-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [/home/test/workspace/test/hdfs:/meta/schemes/common.xml]; nested exception is java.io.FileNotFoundException: /home/test/workspace/test/hdfs:/meta/schemes/common.xml (No such file or directory)

at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)

at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)

at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)

at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:201)

at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:147)

at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:132)

at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:475)

The problem here is that the DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource() method will use ResourcePatternUtils.isUrl() to determine if the path is relative or not. Finally if the path is a valid url or not will be based on the outcome of valuating new URL(resourceLocation). In case a MalformedUrlException is thrown, it will return false and a relative path is build in importBeanDefinitionResource().

The thing to note here is that a MalformedUrlException thrown in the java.lang.net.URL constructor will not indicate a syntactically incorrect url, but only an unkown protocol.

Affects: 3.0 M3

Attachments:

SPR-5762.ZIP (2.78 kB)

Issue Links:

#11032 Cannot import bean definitions using classpath*: resource location ("is duplicated by")

#10998 location parsing might incorrectly rely on the URL API

Referenced from: commits bcc6413

Issue 2:
Mike Youngstrom opened SPR-3280 and commented

I'm using a PropertyPlaceholderConfigurer and I'm using <null/> in some of my bean definitions. After upgrading to 2.0.3 I get the following exception for a configuration using the PropertyPlaceholderConfigurer I don't get this error with 2.0.2 If I don't pass in a <null/> property everything works fine:

SomeBean.java

public class SomeBean {

public void setSomeProperty(Object obj) {

}

}

applicationContext.xml

<bean class="SomeBean">

<property name="testProperty"><null/></property>

</bean>

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false">
<property name="locations">
<list>
<value>classpath:property.properties</value>
</list>
<property/>
</bean>

Exception

java.lang.NullPointerException

at java.lang.StringBuffer.<init>(StringBuffer.java:104)

at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.parseStringValue(PropertyPlaceholderConfigurer.java:270)

at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingBeanDefinitionVisitor.resolveStringValue(PropertyPlaceholderConfigurer.java:401)

at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:143)

at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:89)

at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:59)

at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:246)

at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)

at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:422)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:334)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1185)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1147)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:221)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:111)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1047)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:843)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)

at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:683)

at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:394)

at org.lds.stack.spring.context.WebContextSingletonBeanFactoryLocator.useBeanFactory(WebContextSingletonBeanFactoryLocator.java:38)

at org.lds.stack.spring.context.BootstrapContextLoader.createWebApplicationContext(BootstrapContextLoader.java:30)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)

at org.apache.catalina.core.StandardService.start(StandardService.java:448)

at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)

at org.apache.catalina.startup.Catalina.start(Catalina.java:552)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

Affects: 2.0.3

Issue Links:

#7934 NPE in PropertyPlaceholderConfigurer.parseStringValue because TypedStringValue.getValue() is null ("duplicates")