<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=diwakar" rel="nofollow">diwakar</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7084?redirect=false" rel="nofollow">SPR-7084</a></strong> and commented</p>
<p dir="auto">Code</p>
<hr>
<p dir="auto">import org.springframework.context.support.GenericApplicationContext;<br>
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;<br>
import org.springframework.core.io.ClassPathResource;</p>
<p dir="auto">/**<br>
*/<br>
public class IllegalArgumentProblem {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public static void main(String[] args) {
     GenericApplicationContext parent = new GenericApplicationContext();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(parent);
    reader.loadBeanDefinitions(new ClassPathResource(&quot;app.xml&quot;, IllegalArgumentProblem.class));
    parent.refresh();

    String bean = (String) parent.getBean(&quot;x&quot;);
    String bean2 = (String) parent.getBean(&quot;x&quot;); // second access throws the exception.
}"><pre class="notranslate"><code class="notranslate">public static void main(String[] args) {
     GenericApplicationContext parent = new GenericApplicationContext();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(parent);
    reader.loadBeanDefinitions(new ClassPathResource("app.xml", IllegalArgumentProblem.class));
    parent.refresh();

    String bean = (String) parent.getBean("x");
    String bean2 = (String) parent.getBean("x"); // second access throws the exception.
}
</code></pre></div>
<p dir="auto">}</p>
<p dir="auto">Configuration</p>
<hr>
<p dir="auto">&lt;beans xmlns="<a href="http://www.springframework.org/schema/beans" rel="nofollow">http://www.springframework.org/schema/beans</a>"<br>
xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" rel="nofollow">http://www.w3.org/2001/XMLSchema-instance</a>"<br>
xsi:schemaLocation="<a href="http://www.springframework.org/schema/beans" rel="nofollow">http://www.springframework.org/schema/beans</a><br>
<a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd%22%3E" rel="nofollow">http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean id=&quot;x&quot; class=&quot;java.lang.String&quot; scope=&quot;prototype&quot;&gt;
    &lt;constructor-arg&gt;&lt;value&gt;PARENT value&lt;/value&gt;&lt;/constructor-arg&gt;
&lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">&lt;bean id="x" class="java.lang.String" scope="prototype"&gt;
    &lt;constructor-arg&gt;&lt;value&gt;PARENT value&lt;/value&gt;&lt;/constructor-arg&gt;
&lt;/bean&gt;
</code></pre></div>
<p dir="auto">&lt;/beans&gt;</p>
<p dir="auto">Error</p>
<hr>
<p dir="auto">log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).<br>
log4j:WARN Please initialize the log4j system properly.<br>
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'x' defined in class path resource [app.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.lang.String]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch<br>
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:254)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:823)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)<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.doGetBean(AbstractBeanFactory.java:283)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)<br>
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)<br>
at IllegalArgumentProblem.main(IllegalArgumentProblem.java:21)<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:597)<br>
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)<br>
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.lang.String]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch<br>
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:111)<br>
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)<br>
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:248)<br>
... 16 more<br>
Caused by: java.lang.IllegalArgumentException: argument type mismatch<br>
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)<br>
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)<br>
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)<br>
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)<br>
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)<br>
... 18 more</p>
<p dir="auto">Process finished with exit code 1</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.5, 2.5.6</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="398093748" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10240" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10240/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10240">#10240</a> not singleton StringBeans (<em><strong>"is duplicated by"</strong></em>)</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/12ce250c6ce911774a7983905fd6e006b5a1eac1/hovercard" href="https://github.com/spring-projects/spring-framework/commit/12ce250c6ce911774a7983905fd6e006b5a1eac1"><tt>12ce250</tt></a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=wshields" rel="nofollow">William Shields</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-3390?redirect=false" rel="nofollow">SPR-3390</a></strong> and commented</p>
<p dir="auto">form:errors is a pretty crude mechanism for displaying multiple errors.  It uses a default delimieter of &lt;br&gt;.  It should allow for more sophisticated methods of displaying errors.</p>
<p dir="auto">In the simple case, I would like to see "schemes" introduced.  For example:</p>
<p dir="auto">&lt;form:errors path="*" scheme="ul"/&gt;</p>
<p dir="auto">which would craete:</p>
<p dir="auto">&lt;ul&gt;<br>
&lt;li&gt;error1&lt;/li&gt;<br>
&lt;li&gt;error2&lt;/li&gt;<br>
&lt;/ul&gt;</p>
<p dir="auto">Note: if there were no errors the enclosing &lt;ul&gt; tag should not be rendered.</p>
<p dir="auto">Example schemes could be:</p>
<p dir="auto">table<br>
ul<br>
ol</p>
<p dir="auto">Potentially this may require another attribute to distinguish between the CSS class given to the enclosing tags and that given to each element, although if the enclosing tag got the value of cssClass, a CSS selector could resolve that problem without adding an attribute.</p>
<p dir="auto">In the more complicated example, it is possibly worthwhile (although arguably unnecessary if you have sufficient schemes as defined above) to allow either the programmer to write their own schemes or to have sufficient attributes to achieve the same thing.</p>
<p dir="auto">Example:</p>
<p dir="auto">&lt;form:scheme name="errorTable"&gt;</p>
<p dir="auto">form:pre</p>
<p dir="auto">&lt;table&gt;<br>
&lt;tr&gt;<br>
&lt;th&gt;Error #&lt;/th&gt;<br>
&lt;th&gt;Error Description&lt;/th&gt;<br>
&lt;/tr&gt;<br>
&lt;/form:pre&gt;</p>
<p dir="auto">&lt;form:loop var="count"&gt;</p>
<p dir="auto">&lt;tr&gt;<br>
&lt;td&gt;&lt;c:out value="${count}"/&gt;&lt;/td&gt;<br>
&lt;td&gt;&lt;form:error/&gt;&lt;/td&gt;<br>
&lt;/tr&gt;<br>
&lt;/form:loop&gt;</p>
<p dir="auto">form:post</p>
<p dir="auto">&lt;/table&gt;<br>
&lt;/form:post&gt;</p>
<p dir="auto">&lt;/form:scheme&gt;</p>
<p dir="auto">The simple example of this kind of thing would be adding attributes:</p>
<p dir="auto">&lt;form:errors path="*" block="ul" item="li"/&gt;</p>
<p dir="auto">alternatively have a heading block within:</p>
<p dir="auto">&lt;form:errors path="*" block="ul" item="li"&gt;</p>
<p dir="auto">&lt;p&gt;The following errors have occurred:&lt;/p&gt;<br>
&lt;/form:errors&gt;<br>
Anywa, you get the idea.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0.4</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="398117956" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13859" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13859/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13859">#13859</a> Extend form:errors with something like errorElement (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">20 votes, 14 watchers</p>