[ 
https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581695#action_12581695
 ] 

Alastair Maw commented on WICKET-1130:
--------------------------------------

So this sort of thing is a limitation in cglib. We need to proxy the class 
using an Enhancer, so that it can be serialized, and the class needs to have a 
zero-arg constructor in order for cglib to be able to do that.

I don't understand why this is failing for you, as you should surely be 
injecting against an interface, in which case this should work just fine.

I.e:
bind(javax.persistence.EntityManager.class).toInstance(hibernateEntityManager) 
or whatever.

So no, this probably isn't ever going to be fixed, as it's pretty much 
impossible to do so.

There are two alternatives:
 - We inject the object, not a proxy. This will either cause serialization 
errors (in your case), or the session size to blow up. Neither sounds good.
 - We get clever about serializing/deserializing pages, and effectively do the 
"proxying" there. We'd probably need to require annotations for this - it's not 
going to make it in before 1.4.

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