Issue 1:
diwakar opened SPR-7084 and commented

Code

import org.springframework.context.support.GenericApplicationContext;

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

import org.springframework.core.io.ClassPathResource;

/**

*/

public class IllegalArgumentProblem {

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.
}

}

Configuration

<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="x" class="java.lang.String" scope="prototype">
<constructor-arg><value>PARENT value</value></constructor-arg>
</bean>

</beans>

Error

log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).

log4j:WARN Please initialize the log4j system properly.

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

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:254)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:823)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)

at java.security.AccessController.doPrivileged(Native Method)

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

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:283)

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

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

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

at IllegalArgumentProblem.main(IllegalArgumentProblem.java:21)

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:597)

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

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

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:111)

at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:248)

... 16 more

Caused by: java.lang.IllegalArgumentException: argument type mismatch

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)

... 18 more

Process finished with exit code 1

Affects: 2.5.5, 2.5.6

Issue Links:

#10240 not singleton StringBeans ("is duplicated by")

Referenced from: commits 12ce250

Issue 2:
William Shields opened SPR-3390 and commented

form:errors is a pretty crude mechanism for displaying multiple errors. It uses a default delimieter of <br>. It should allow for more sophisticated methods of displaying errors.

In the simple case, I would like to see "schemes" introduced. For example:

<form:errors path="*" scheme="ul"/>

which would craete:

<ul>

<li>error1</li>

<li>error2</li>

</ul>

Note: if there were no errors the enclosing <ul> tag should not be rendered.

Example schemes could be:

table

ul

ol

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.

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.

Example:

<form:scheme name="errorTable">

form:pre

<table>

<tr>

<th>Error #</th>

<th>Error Description</th>

</tr>

</form:pre>

<form:loop var="count">

<tr>

<td><c:out value="${count}"/></td>

<td><form:error/></td>

</tr>

</form:loop>

form:post

</table>

</form:post>

</form:scheme>

The simple example of this kind of thing would be adding attributes:

<form:errors path="*" block="ul" item="li"/>

alternatively have a heading block within:

<form:errors path="*" block="ul" item="li">

<p>The following errors have occurred:</p>

</form:errors>

Anywa, you get the idea.

Affects: 2.0.4

Issue Links:

#13859 Extend form:errors with something like errorElement ("is duplicated by")

20 votes, 14 watchers