[ 
https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eelco Hillenius updated WICKET-1130:
------------------------------------

    Attachment: GuiceLazyInitProxyFactory.java

Amazing that this issue has been unresolved for such a long time: it isn't that 
hard to fix, and without the fix it makes Guice integration with Wicket really 
a whole lot less attractive. I never realized because while I've been using 
Guice for a while, I hadn't used it together with Wicket yet.

Anyway, attached is a partial fix that I use for a system I work on. I've had 
this fix for a while, hoping I could find time to properly implement it for 
Wicket, but alas, I haven't found the time to do that just yet. So I'm 
attaching my fix and idea here so that if anyone else has a few spare cycles, 
at least the idea is there.

The main change is the replacement of LazyInitProxyFactory so that:
1) rather than constructing instances through reflection, ask the Guice 
injector to give an instance
2) if there is a non-default constructor annotated with @Inject, use these 
parameters (and dummy values) for constructing the proxy

Having looked at this issue, I also wonder if 1) shouldn't be done for Spring 
also.

Looks to me like it can't be fixed without breaking at least some parts of the 
API, though it'll be internal for most users.

> Injection of Bound Instance Fails with Exception
> ------------------------------------------------
>
>                 Key: WICKET-1130
>                 URL: https://issues.apache.org/jira/browse/WICKET-1130
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-guice
>    Affects Versions: 1.3.0-beta4
>            Reporter: Daniel Spiewak
>            Assignee: Alastair Maw
>             Fix For: 1.5-M1
>
>         Attachments: GuiceLazyInitProxyFactory.java
>
>
> If I try to inject an explicitly bound instance into a component, injection 
> fails with an exception in the creation of the CGLIB proxy:
> java.lang.IllegalArgumentException: Superclass has no null constructors but 
> no arguments were given
> Stupidly, I forgot to save the whole stack trace and the code is now gone 
> from my codebase (since I needed it to work).  To repeat:
> @Override
> public void configure() {
>     bind(EntityManager.class).toInstance(manager);
> }
> Seems wicket-guice is assuming that it needs to create a new instance of 
> everything that's injected, and since EntityManager doesn't have a no-args 
> constructor, such an action fails.  Just an assumption anyway...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to