<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=spod" rel="nofollow">Stefan Podkowinski</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-5762?redirect=false" rel="nofollow">SPR-5762</a></strong> and commented</p>
<p dir="auto">I've written a custom resource loader that is supposed to handle protocol "hdfs://" and registered the loader with the XmlBeanDefinitionReader as follows:</p>
<p dir="auto">XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);<br>
reader.setResourceLoader(resourceLoader);</p>
<p dir="auto">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:</p>
<p dir="auto">&lt;beans&gt;<br>
&lt;import resource="hdfs:///meta/schemes/common.xml"/&gt;<br>
&lt;/beans&gt;</p>
<p dir="auto">The following exception will occur:</p>
<p dir="auto">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]<br>
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)<br>
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)<br>
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)<br>
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)<br>
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:201)<br>
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:147)<br>
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:132)<br>
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)<br>
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:475)</p>
<p dir="auto">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().</p>
<p dir="auto">The thing to note here is that a MalformedUrlException thrown in the java.lang.net.URL constructor will <strong>not</strong> indicate a syntactically incorrect url, but only an unkown protocol.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 M3</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/15919/SPR-5762.ZIP" rel="nofollow">SPR-5762.ZIP</a> (<em>2.78 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398099258" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/11032" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/11032/hovercard" href="https://github.com/spring-projects/spring-framework/issues/11032">#11032</a> Cannot import bean definitions using classpath*: resource location (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398099057" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10998" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10998/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10998">#10998</a> location parsing might incorrectly rely on the URL API</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/bcc6413ef75b563e93bf815153babe730da64918/hovercard" href="https://github.com/spring-projects/spring-framework/commit/bcc6413ef75b563e93bf815153babe730da64918"><tt>bcc6413</tt></a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=youngm" rel="nofollow">Mike Youngstrom</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-3280?redirect=false" rel="nofollow">SPR-3280</a></strong> and commented</p>
<p dir="auto">I'm using a PropertyPlaceholderConfigurer and I'm using &lt;null/&gt; 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 &lt;null/&gt; property everything works fine:</p>
<p dir="auto">SomeBean.java<br>
public class SomeBean {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public void setSomeProperty(Object obj) {
	
}"><pre class="notranslate"><code class="notranslate">public void setSomeProperty(Object obj) {
	
}
</code></pre></div>
<p dir="auto">}</p>
<p dir="auto">applicationContext.xml<br>
&lt;bean class="SomeBean"&gt;<br>
&lt;property name="testProperty"&gt;&lt;null/&gt;&lt;/property&gt;<br>
&lt;/bean&gt;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot; lazy-init=&quot;false&quot;&gt;
	&lt;property name=&quot;locations&quot;&gt;
		&lt;list&gt;
			&lt;value&gt;classpath:property.properties&lt;/value&gt;
                    &lt;/list&gt;
            &lt;property/&gt;
&lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false"&gt;
	&lt;property name="locations"&gt;
		&lt;list&gt;
			&lt;value&gt;classpath:property.properties&lt;/value&gt;
                    &lt;/list&gt;
            &lt;property/&gt;
&lt;/bean&gt;
</code></pre></div>
<p dir="auto">Exception</p>
<p dir="auto">java.lang.NullPointerException<br>
at java.lang.StringBuffer.&lt;init&gt;(StringBuffer.java:104)<br>
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.parseStringValue(PropertyPlaceholderConfigurer.java:270)<br>
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingBeanDefinitionVisitor.resolveStringValue(PropertyPlaceholderConfigurer.java:401)<br>
at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:143)<br>
at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:89)<br>
at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:59)<br>
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:246)<br>
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)<br>
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:422)<br>
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:334)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
at java.lang.reflect.Method.invoke(Method.java:585)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1185)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1147)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)<br>
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:221)<br>
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:111)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1047)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:843)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)<br>
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:683)<br>
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:394)<br>
at org.lds.stack.spring.context.WebContextSingletonBeanFactoryLocator.useBeanFactory(WebContextSingletonBeanFactoryLocator.java:38)<br>
at org.lds.stack.spring.context.BootstrapContextLoader.createWebApplicationContext(BootstrapContextLoader.java:30)<br>
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)<br>
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)<br>
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)<br>
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)<br>
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)<br>
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)<br>
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)<br>
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)<br>
at org.apache.catalina.core.StandardService.start(StandardService.java:448)<br>
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)<br>
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
at java.lang.reflect.Method.invoke(Method.java:585)<br>
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)<br>
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0.3</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398076152" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7934" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7934/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7934">#7934</a> NPE in PropertyPlaceholderConfigurer.parseStringValue because TypedStringValue.getValue() is null (<em><strong>"duplicates"</strong></em>)</li>
</ul>