You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jan Kriesten <ja...@renitence.de> on 2008/10/20 08:53:15 UTC

wicket-ioc/cglib & constructor injection

Hi,

wicket-ioc/cglib (using 1.3-snapshot) has problems when it comes to creating
proxies for constructor injection (and also when it comes to enhance final classes):

Caused by: java.lang.IllegalArgumentException: Superclass has no null
constructors but no arguments were given
        at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:721)
        at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
        at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
        at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
        at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
        at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
        at
org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:173)
        at
org.apache.wicket.guice.GuiceComponentInjector.inject(GuiceComponentInjector.java:114)


Is there a way around this or could the above cases just handled to not be
enhanced at all?

Best regards, --- Jan.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-ioc/cglib & constructor injection

Posted by Igor Vaynberg <ig...@gmail.com>.
On Mon, Oct 20, 2008 at 1:30 AM, Jan Kriesten <ja...@renitence.de> wrote:
>
> Hi Igor,
>
> > add a package private default constructor to your class.
>
> default constructor wont work in this case.

why not? you dont own the class? then you have to use something like
salve. btw, if wicket cant create a proxy then neither will spring if
it needs to.

> > these are all well known limitations of proxying classes, you should try to
> > make sure your injected dependencies are interfaces or you something like
> > salve so no proxies are needed.
>
> Defining an interface for the class results in wicket-ioc not injecting the
> original class/constructor at all. So there's a flaw with this approach.

there is no flaw. extract an interface, make sure the class implements
it and inject the interface.

-igor

>
> Best regards, --- Jan.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-ioc/cglib & constructor injection

Posted by Jan Kriesten <ja...@renitence.de>.
Hi Igor,

> add a package private default constructor to your class.

default constructor wont work in this case.

> these are all well known limitations of proxying classes, you should try to
> make sure your injected dependencies are interfaces or you something like
> salve so no proxies are needed.

Defining an interface for the class results in wicket-ioc not injecting the
original class/constructor at all. So there's a flaw with this approach.

Best regards, --- Jan.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-ioc/cglib & constructor injection

Posted by Igor Vaynberg <ig...@gmail.com>.
add a package private default constructor to your class.

these are all well known limitations of proxying classes, you should try to
make sure your injected dependencies are interfaces or you something like
salve so no proxies are needed.

-igor

On Sun, Oct 19, 2008 at 11:53 PM, Jan Kriesten <ja...@renitence.de>wrote:

>
> Hi,
>
> wicket-ioc/cglib (using 1.3-snapshot) has problems when it comes to
> creating
> proxies for constructor injection (and also when it comes to enhance final
> classes):
>
> Caused by: java.lang.IllegalArgumentException: Superclass has no null
> constructors but no arguments were given
>        at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:721)
>        at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
>        at
>
> net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
>        at
>
> net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
>        at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
>        at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
>        at
>
> org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:173)
>        at
>
> org.apache.wicket.guice.GuiceComponentInjector.inject(GuiceComponentInjector.java:114)
>
>
> Is there a way around this or could the above cases just handled to not be
> enhanced at all?
>
> Best regards, --- Jan.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>