You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Uwe Schäfer <sc...@thomas-daily.de> on 2007/11/15 14:38:07 UTC
IOC problem
Hi
I´m using Guice with Wicket and i´m quite happy with it. Now I have a
problem with the IOC, and i think, i´d need some help there :)
I have a service-class X
public class X{
@Inject public X(Y y)
{
...
}
}
bound like this:
bind(X.class).in(MyScopes.SOMETHING);
bind(Y.class).to(SomeYImpl.class);
I´m trying to use it in a page:
public class P extends WebPage{
@Inject
private X x;
public P(){
...
x.foo();
}
}
What i see is this:
java.lang.IllegalArgumentException: Superclass has no null constructors
but no arguments were given
at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:718)
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:164)
at
org.apache.wicket.guice.GuiceComponentInjector.inject(GuiceComponentInjector.java:112)
at
org.apache.wicket.guice.GuiceComponentInjector.onInstantiation(GuiceComponentInjector.java:193)
at
org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:973)
at org.apache.wicket.Component.<init>(Component.java:865)
at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:104)
at org.apache.wicket.Page.<init>(Page.java:230)
The obvious problem can be found in LazyInitProxyFactory:
CGLibInterceptor handler = new CGLibInterceptor(type, locator);
Enhancer e = new Enhancer();
e.setInterfaces(new Class[] { Serializable.class, ILazyInitProxy.class,
IWriteReplace.class });
e.setSuperclass(type);
e.setCallback(handler);
return e.create(); // <-- !
Is it currently impossible to use constructor injection ?
cu uwe
--
THOMAS DAILY GmbH
Adlerstraße 19
79098 Freiburg
Deutschland
T + 49 761 3 85 59 0
F + 49 761 3 85 59 550
E schaefer@thomas-daily.de
www.thomas-daily.de
Geschäftsführer/Managing Directors:
Wendy Thomas, Susanne Larbig
Handelsregister Freiburg i.Br., HRB 3947
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: IOC problem
Posted by Al Maw <wi...@almaw.com>.
Uwe Schäfer wrote:
>> Is it currently impossible to use constructor injection ?
>
> To quickly answer my own question: no, but little tricky! :)
Well, you need to replace instances of new FooComponent() with something
that gets injected, like a Provider<Foo> if you're using Guice, or some
kind of bean factory if you use Spring.
> I´d like to share the experience to the wiki or wherever the right
> place for 'little gotchas' is.
>
> Is there a place where you can find wicket-guice notes already?
Not really. Feel free to add like Gwyn said.
Regards,
Al
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: IOC problem
Posted by Uwe Schäfer <sc...@thomas-daily.de>.
Gwyn Evans schrieb:
> but I'd suggest that the
> correct place would be in a page below the "Integration guides" page
thanks, will do that on Sunday.
--
THOMAS DAILY GmbH
Adlerstraße 19
79098 Freiburg
Deutschland
T + 49 761 3 85 59 0
F + 49 761 3 85 59 550
E schaefer@thomas-daily.de
www.thomas-daily.de
Geschäftsführer/Managing Directors:
Wendy Thomas, Susanne Larbig
Handelsregister Freiburg i.Br., HRB 3947
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: IOC problem
Posted by Gwyn Evans <gw...@gmail.com>.
There's nothing on the Wiki at the moment, but I'd suggest that the
correct place would be in a page below the "Integration guides" page
at http://cwiki.apache.org/WICKET/integration-guides.html. Just go
there, then "Add page" and it should automatically appear in the
"Reference page/Integration Guides" list.
/Gwyn
On 15/11/2007, Uwe Schäfer <sc...@thomas-daily.de> wrote:
> Uwe Schäfer schrieb:
>
> > Is it currently impossible to use constructor injection ?
>
> To quickly answer my own question: no, but little tricky! :)
> I´d like to share the experience to the wiki or wherever the right place
> for 'little gotchas' is.
>
> Is there a place where you can find wicket-guice notes already?
>
> Al?
>
> cu uwe
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Download Wicket 1.3.0-rc1 now! - http://wicketframework.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: IOC problem
Posted by Uwe Schäfer <sc...@thomas-daily.de>.
Uwe Schäfer schrieb:
> Is it currently impossible to use constructor injection ?
To quickly answer my own question: no, but little tricky! :)
I´d like to share the experience to the wiki or wherever the right place
for 'little gotchas' is.
Is there a place where you can find wicket-guice notes already?
Al?
cu uwe
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org