You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by RedCarpet <bl...@gmx.com> on 2015/01/06 02:04:27 UTC
SpringBean doesn't support Generics?
Spring 4 is able to wire/inject generic beans, as described here:
http://spring.io/blog/2013/12/03/spring-framework-4-0-and-java-generics .
However, I'm experiencing problems when using generic beans with Wicket's
SpringBean.
I basically have following situation, two concrete dao's that implement a
generic typed interface dao.:
class Product{}
class Car extends Product{}
class Phone extends Product{}
interface ProductDao<T extends Product> {}
class CarProductDao implements ProductDao<Car> {}
class PhoneProductDao implements ProductDao<Phone> {}
class ProductModel<T extends Product> extends LoadableDetachableModel<T> {
@SpringBean ProductDao<T> productDao;
}
class ProductPage extends WebPage {
...
ProductModel<CarProduct> model = new ProductModel<CarProduct>(product);
...
}
This will result in the following error:
2015-jan-06;01:53:23.471 http-nio-8080-exec-6 WARN RequestCycleExtra -
Handling the following exception
java.lang.IllegalStateException: More than one bean of type [ProductDao]
found, you have to specify the name of the bean (@SpringBean(name="foo")) or
(@Named("foo") if using @javax.inject classes) in order to resolve this
conflict. Matched beans: carProductDao,phoneProductDao
at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanNameOfClass(AnnotProxyFieldValueFactory.java:289)
~[AnnotProxyFieldValueFactory.class:6.18.0]
at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanName(AnnotProxyFieldValueFactory.java:198)
~[AnnotProxyFieldValueFactory.class:6.18.0]
at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:130)
~[AnnotProxyFieldValueFactory.class:6.18.0]
at org.apache.wicket.injection.Injector.inject(Injector.java:111)
~[Injector.class:6.18.0]
at
org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)
~[SpringComponentInjector.class:6.18.0]
at ProductModel.<init>(ProductModel.java:20) ~[ProductModel.class:na]
at ProductPage$15.populateItem(ProductPage.java:742)
~[ProductPage$15.class:na]
Does Wicket's SpringBean support Spring-4's generics support?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/SpringBean-doesn-t-support-Generics-tp4668928.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: SpringBean doesn't support Generics?
Posted by RedCarpet <bl...@gmx.com>.
Hi, I have just created a ticket here with a quickstart to demo the problem:
https://issues.apache.org/jira/browse/WICKET-5808
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/SpringBean-doesn-t-support-Generics-tp4668928p4668937.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: SpringBean doesn't support Generics?
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
Please create a ticket with a quickstart.
With a patch would be awesome!
Thanks!
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Tue, Jan 6, 2015 at 3:04 AM, RedCarpet <bl...@gmx.com> wrote:
> Spring 4 is able to wire/inject generic beans, as described here:
> http://spring.io/blog/2013/12/03/spring-framework-4-0-and-java-generics .
> However, I'm experiencing problems when using generic beans with Wicket's
> SpringBean.
>
> I basically have following situation, two concrete dao's that implement a
> generic typed interface dao.:
> class Product{}
> class Car extends Product{}
> class Phone extends Product{}
> interface ProductDao<T extends Product> {}
> class CarProductDao implements ProductDao<Car> {}
> class PhoneProductDao implements ProductDao<Phone> {}
>
> class ProductModel<T extends Product> extends LoadableDetachableModel<T> {
> @SpringBean ProductDao<T> productDao;
> }
> class ProductPage extends WebPage {
> ...
> ProductModel<CarProduct> model = new ProductModel<CarProduct>(product);
> ...
> }
>
> This will result in the following error:
> 2015-jan-06;01:53:23.471 http-nio-8080-exec-6 WARN RequestCycleExtra -
> Handling the following exception
> java.lang.IllegalStateException: More than one bean of type [ProductDao]
> found, you have to specify the name of the bean (@SpringBean(name="foo"))
> or
> (@Named("foo") if using @javax.inject classes) in order to resolve this
> conflict. Matched beans: carProductDao,phoneProductDao
> at
>
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanNameOfClass(AnnotProxyFieldValueFactory.java:289)
> ~[AnnotProxyFieldValueFactory.class:6.18.0]
> at
>
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanName(AnnotProxyFieldValueFactory.java:198)
> ~[AnnotProxyFieldValueFactory.class:6.18.0]
> at
>
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:130)
> ~[AnnotProxyFieldValueFactory.class:6.18.0]
> at org.apache.wicket.injection.Injector.inject(Injector.java:111)
> ~[Injector.class:6.18.0]
> at
>
> org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)
> ~[SpringComponentInjector.class:6.18.0]
> at ProductModel.<init>(ProductModel.java:20)
> ~[ProductModel.class:na]
> at ProductPage$15.populateItem(ProductPage.java:742)
> ~[ProductPage$15.class:na]
>
>
>
> Does Wicket's SpringBean support Spring-4's generics support?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/SpringBean-doesn-t-support-Generics-tp4668928.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>