You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Daniel Spiewak (JIRA)" <ji...@apache.org> on 2007/11/05 15:50:50 UTC

[jira] Created: (WICKET-1130) Injection of Bound Instance Fails with Exception

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


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.


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frank Bille Jensen updated WICKET-1130:
---------------------------------------

    Fix Version/s:     (was: 1.3.0-rc2)
                   1.3.0-rc3

> 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.0-rc3
>
>
> 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.


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Tuomas Karkkainen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12634880#action_12634880 ] 

Tuomas Karkkainen commented on WICKET-1130:
-------------------------------------------

injecting concrete classes without zero argument constructor into wicket components fails, even if the injection is properly configured.  

I have this:

public ConcreteClass(String a, String b) { ... }
bind(ConcreteClass.class).toInstance(new ConcreteClass("a","b"));

if I have

@Inject
private ConcreteClass concreteClass 

in a wicket component it will not be injected but cglib will complain.  If I have it instead in a secondary dependency guice will inject it fine, which is confusing. e.g.

public class ConcreteClassHolder {
 @Inject 
 private ConcreteClass concreteClass;
 public getConcreteClass(){...}
}
public class SomethingPanel extends Panel{
 @Inject
 private ConcreteClassHolder concreteClassHolder;
}
 

Instead of confusingly failing, with a "Superclass has no null constructors but no arguments were given", I would prefer wicket to atleast check for this condition in LazyInitProxyFactory:

public static Object createProxy(final Class type, final IProxyTargetLocator locator) {
...
return e.create(); 
}

with maybe:

        try {
                return e.create();
            } catch (final IllegalArgumentException iae) {
                throw new RuntimeException("Cannot proxy concrete class with no zero args constructor here, use an interface or see JIRA issue WICKET-1130.");
            }


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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Daniel Spiewak (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581756#action_12581756 ] 

Daniel Spiewak commented on WICKET-1130:
----------------------------------------

Thought about that, but there's two problems.  First, it's a public API, so even if it is my project I don't want to mess too much with it.  More importantly though, the class actually needs those constructor parameters in order to do anything useful.  I suppose though that cglib is actually creating a delegate proxy, so it would still work.  I wonder if a possible workaround would be to derive a class from EntityManager which has a package-private default constructor, then bind to this instance.  Would be a bit ugly though since every usage of EntityManager in code would have to be changed to use this internal deviant.

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


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg updated WICKET-1130:
----------------------------------

    Fix Version/s: 1.5-M3
                       (was: 1.5-M2)

> 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
>             Fix For: 1.5-M3
>
>         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.


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frank Bille Jensen updated WICKET-1130:
---------------------------------------

    Fix Version/s:     (was: 1.3.1)
                   1.3.2

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


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Jeremy Thomerson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeremy Thomerson updated WICKET-1130:
-------------------------------------

    Fix Version/s:     (was: 1.5-M3)
                   1.5-M4

> 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
>             Fix For: 1.5-M4
>
>
> 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.


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635375#action_12635375 ] 

Igor Vaynberg commented on WICKET-1130:
---------------------------------------

hmm, i gues you were injecting a class, disregard my earlier comment.

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635374#action_12635374 ] 

Igor Vaynberg commented on WICKET-1130:
---------------------------------------

interesting because i thought you were injecting an interface.in which case a jdk proxy is used instead of the cglib one....

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


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
     [ 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.


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Attachment:     (was: GuiceLazyInitProxyFactory.java)

> 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
>             Fix For: 1.5-M3
>
>
> 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.


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581754#action_12581754 ] 

Igor Vaynberg commented on WICKET-1130:
---------------------------------------

which is a shame, because if it was an interface it would work just fine :) what you can try is adding a package-level default constructor. that way cglib can create the subclass and no one outside your api will see it.

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Alastair Maw (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg updated WICKET-1130:
----------------------------------

    Fix Version/s:     (was: 1.3.3)
                   1.5-M1

moving this to 1.5.

basically when injecting instances of concrete classes we are limited by cglib which requires a default visible constructor and no final methods so that it can create a subclass for our proxy.

once we switch to jdk5 we can require usage of annotations for injection and then we can remove the proxies and use hooks in page serialization to inject objects and hooks in deserialzation to make sure injected fields are skipped.

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


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frank Bille Jensen updated WICKET-1130:
---------------------------------------

    Fix Version/s:     (was: 1.3.2)
                   1.3.3

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12896730#action_12896730 ] 

Eelco Hillenius commented on WICKET-1130:
-----------------------------------------

@Casper there isn't really a meaningful way to include more as that's specific to my app.

The meat of the trick is just this:

{code:java}
	final Parameters parameters = new Parameters();
	for (Constructor c : originalType.getConstructors()) {
		if (c.getParameterTypes().length == 0) {
			// ok, we're good, default constructor
			break;
		} else if (c.getAnnotations().length > 0) {
			for (Annotation a : c.getAnnotations()) {
				if (Inject.class.isAssignableFrom(a.getClass())) {
					// ah, we have a guice injector
					parameters.parameterTypes = c.getParameterTypes();
				}
			}
		}
	}
	if (parameters.parameterTypes != null) {
		Object[] dummyArgs = new Object[parameters.parameterTypes.length];
		for (int i = 0; i < dummyArgs.length; i++) {
			dummyArgs[i] = null;
		}
		parameters.dummyArgs = dummyArgs;
	}
{code}

in the else branch of createProxy (which is activated when the type is not a primitive or an interface) and then at the end of the method:

{code:java}
	Object proxy = null;
	if (parameters.parameterTypes == null) {
		proxy = e.create();
	} else {
		proxy = e.create(parameters.parameterTypes,
				parameters.dummyArgs);
	}
{code}

And then in between those blocks:

{code:java}
	Enhancer e = new Enhancer() {
		@Override
		protected Object firstInstance(Class type) throws Exception {
			Object instance = null;
			Method setter = type.getDeclaredMethod(
					"CGLIB$SET_THREAD_CALLBACKS",
					new Class[] { Callback[].class });
			setter.invoke(null,
					new Object[] { new Callback[] { handler } });
			try {

				instance = GuiceComponentInjector.getInjector()
						.getInstance(type);
			} finally {
				setter.invoke(null, new Object[] { null });
			}
			return instance;
		}
	};
{code}

which overrides the default behavior of Enhancer by using a Guice Injector instance to get the 'first instance' rather than trying to construct it through regular Java reflection.

If you'd dig deeper (again sorry I don't have the spare cycles myself), you could probably do this neater by writing a custom Enhancer rather than extending the current one; you may be able to get around doing the constructor arguments introspection to start with if you do that. For now, this code works but the main difficulty is where to get the Guice Injector instance from: LazyInitProxyFactory currently is independent of which DI framework is used, so it'll probably require a API break to get this done properly in Wicket.

> 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
>             Fix For: 1.5-M2
>
>         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.


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frank Bille Jensen updated WICKET-1130:
---------------------------------------

    Fix Version/s:     (was: 1.3.0-rc3)
                   1.3.1

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12634909#action_12634909 ] 

Igor Vaynberg commented on WICKET-1130:
---------------------------------------

unfortunately this is a limitation of java/cglb. easiest thing to do is to add a package-private noarg constructor to the class. was this the underlying reason for your previous troubles?

i cant say that i agree with your patch either, there may be other reasons why IllegalArgumentException is thrown from e.create() no?

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


[jira] Assigned: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eelco Hillenius reassigned WICKET-1130:
---------------------------------------

    Assignee:     (was: Alastair Maw)

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Alastair Maw (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581639#action_12581639 ] 

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

This is getting looked at right now. Will keep you posted.

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909520#action_12909520 ] 

Eelco Hillenius commented on WICKET-1130:
-----------------------------------------

Hmmmpfff, well, seems like there still can be issues with it, so scratch this. See http://stackoverflow.com/questions/1706751 for the problem. We probably need to rewrite gclib out of it in order to make this work.

> 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
>             Fix For: 1.5-M3
>
>
> 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.


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg updated WICKET-1130:
----------------------------------

    Fix Version/s: 1.5-M2
                       (was: 1.5-M1)

> 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
>             Fix For: 1.5-M2
>
>         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.


[jira] Updated: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner updated WICKET-1130:
------------------------------------

    Fix Version/s: 1.3.0-rc2
         Assignee: Alastair Maw

> 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.0-rc2
>
>
> 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.


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Chris Davies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12555704#action_12555704 ] 

Chris Davies commented on WICKET-1130:
--------------------------------------

Reproduced the behaviour by creating a simple singleton (SomeSingleton) and tried to @Inject it into a page after binding the same way as described.  Root cause stack trace is:

java.lang.IllegalArgumentException: No visible constructors in class foo.SomeSingleton
     at net.sf.cglib.proxy.Enhancer.filterConstructors(Enhancer.java:531)
     at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:448)
     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)
     at org.apache.wicket.markup.html.WebPage.<init>(WebPage.java:185)
     at foo.TestPage.<init>(TestPage.java:20)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     at java.lang.Class.newInstance0(Class.java:355)
     at java.lang.Class.newInstance(Class.java:308)
     at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:58)
     at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:262)
     at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:283)
     at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:210)
     at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:90)
     at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1094)
     at org.apache.wicket.RequestCycle.step(RequestCycle.java:1169)
     at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1248)
     at org.apache.wicket.RequestCycle.request(RequestCycle.java:489)
     at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:343)
     at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:193)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
     at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
     at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
     at org.mortbay.jetty.Server.handle(Server.java:313)
     at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
     at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
     at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
     at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581759#action_12581759 ] 

Igor Vaynberg commented on WICKET-1130:
---------------------------------------

even though the api is public, if you add a package-private constructor no one will see it outside of the classes that live in the same package - which of course should only be your classes. so there is really no harm...but really you should consider making it an interface, i dont know if you thought about unit testing or not, but people will probably want to mock the entity manager and if it is an interface it will be that much easier.

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Caspar MacRae (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12895220#action_12895220 ] 

Caspar MacRae commented on WICKET-1130:
---------------------------------------



@Eelco would you please attach the rest of the source?

I've only looked at this briefly, but am guessing you've had to refactor back from GuiceComponentInjector down to the underlying Inject interface to pass the type back.

thanks.

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Daniel Spiewak (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581748#action_12581748 ] 

Daniel Spiewak commented on WICKET-1130:
----------------------------------------

Ok, I can happily wait.  I figured it was going to be a bit of a sticky issue, but I was still hopeful.

BTW, I'm not injecting an interface but an actual class.  EntityManager is a class in ActiveObjects which shares the same name as the interface in JPA (they serve almost identical purposes).

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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Tuomas Karkkainen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635343#action_12635343 ] 

Tuomas Karkkainen commented on WICKET-1130:
-------------------------------------------

Yes, adding the noarg constructor is a solution.  Finding it, based on the error message thrown is some trouble, especially given it works when the injection is in an injected child.  In our case its a third party class too, which adds some trouble for us.

I agree the patch is lousy.


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


[jira] Commented: (WICKET-1130) Injection of Bound Instance Fails with Exception

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581286#action_12581286 ] 

Igor Vaynberg commented on WICKET-1130:
---------------------------------------

it will get looked at whenever Al has time or someone comes up with a patch. i think Al is the only one from the core team using guice so the rest of us have no idea what the problem is or how to fix it.

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