<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=janders" rel="nofollow">Jon Anderson</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-186?redirect=false" rel="nofollow">SPR-186</a></strong> and commented</p>
<p dir="auto">Attached is patch to Errors, EscapedErrors, and BindException that allows the nested path used for validation to be manipulated like a stack with a popNestedPath and a pushNestedPath methods.</p>
<p dir="auto">Being able to nest forms together can save a lot of time and development effort.  Nesting validators has the same effect.  However, it's difficult to nest validators because the path used in errors needs to be set absolutely. So if a Validator makes use of a SubValidator for a portion of it's work, it might need to modify the nestedPath and return it to it's previous state before leaving the validate() method.  For example.  A PersonForm has a AddressForm, and is validated with a PersonValidator that makes use of a AddressValidator.  The validate method for PersonValidator would be as follows:</p>
<p dir="auto">public void validate() {<br>
//other field validation here.<br>
pushNestedPath("address");<br>
addressValidator().validate();<br>
popNestedPath();<br>
}</p>
<p dir="auto">This way the PersonForm can be nested into other forms, such as CompanyForm,  ApplicationForm, etc, without code changes.</p>
<hr>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/10116/nestedPath.patch" rel="nofollow">nestedPath.patch</a> (<em>2.86 kB</em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=alankstewart" rel="nofollow">Alan Stewart (personal account)</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4683?redirect=false" rel="nofollow">SPR-4683</a></strong> and commented</p>
<p dir="auto">Since upgrading from 2.5.2 to 2.5.3 I am getting a NullPointerException when attempting to load a org.springframework.context.support.ResourceBundleMessageSource in  a context file that is imported by a parent context file, eg.</p>
<p dir="auto">&lt;beans ....<br>
&lt;import resource="classpath:applicationContext-core.xml" /&gt;<br>
...<br>
&lt;/beans&gt;</p>
<p dir="auto">where the "messageSource" bean is contained in the imported resource.</p>
<p dir="auto">This did not happen with 2.5.2.  After doing a search in the changelog for 2.5.3 here in JIRA, I can't seem to find an explanation why.</p>
<p dir="auto">The following stack trace is generated on startup of the container:<br>
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource' defined in class path resource [applicationContext-core.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)<br>
at java.security.AccessController.doPrivileged(Native Method)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168)<br>
at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:628)<br>
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)<br>
at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)<br>
at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)<br>
at au.com.woolworths.pap.server.PapTcpServer.main(PapTcpServer.java:82)<br>
Caused by: java.lang.NullPointerException<br>
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.getCacheKey(AbstractAutoProxyCreator.java:322)<br>
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.predictBeanType(AbstractAutoProxyCreator.java:245)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:531)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1174)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:222)<br>
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187)<br>
at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:73)<br>
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:98)<br>
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:84)<br>
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)<br>
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:345)<br>
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:309)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:361)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1342)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)<br>
... 13 more</p>
<p dir="auto">Alan</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.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="398087407" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/9381" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/9381/hovercard" href="https://github.com/spring-projects/spring-framework/issues/9381">#9381</a> Use of factory-method caused application to fail in 2.5.3 but worked under all other previous 2.5 versions. (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">3 votes, 2 watchers</p>