OK, I managed to "fix" the problem. And here`s how:

I used to have Form class injected in page, then Dao class injected in form, then hibernate session injected in dao class and that session was the one causing WicketNotSerializableException. But, when I create the form with new, it all goes away. While this will work, I still think it would be more... well, neat to have components injected on page.
Some things you may look at

IComponentInitalizationListener -- http://wicket.apache.org/apidocs/1.4/org/apache/wicket/application/IComponentInitializationListener.html

IComponentInstantiationListener -- http://wicket.apache.org/apidocs/1.4/org/apache/wicket/application/IComponentInstantiationListener.html

If your really wanting to use Guice/Spring have you considered using a panel/component and implementing your own provider/factory for the component? I'ts almost always harder to do this sort of thing with a Page.



On Tue, Feb 22, 2011 at 3:20 PM, Dan Griffin <dangri...@gmail.com <mailto:dangri...@gmail.com>> wrote:

    Thanks, that does offer more flexibility, but it hasn`t solved my
    problem yet. Guicier and wicket-guice both return objects with
    wicket, not guice proxy when I say something like
    setResponse(HomePage.class). If I inject my page object and say,
    for example, setResponse(injectedPage) it works fine, but I can`t
    stick to that course throughout my application, because
    Application.getHome() returns Class<? extends Page>.

    By the way, the application doesn`t crash, it only throws
    
org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException:
    Unable to serialize class: com.google.inject.InjectorImpl$4 and
    then it continues doing whatever it was doing.

    I found that similar issue was raised before
    <http://osdir.com/ml/users-wicket.apache.org/2009-06/msg01059.html>,
    if it was resolved I would be happy to know. :)

        Take a look at http://code.google.com/p/jolira-tools/wiki/guicier
        <http://code.google.com/p/jolira-tools/wiki/guicier>There is
        an extended
        integration with Guice.

        On Mon, Feb 21, 2011 at 5:16 PM, Dan
        Griffin<dangri...@gmail.com <mailto:dangri...@gmail.com>>  wrote:


            Sorry for spamming, but I remembered another thing I would
            like to ask
            related to this. The reason why I need to inject a page is
            because I would
            like to use guice AOP feature to wrap an interceptor
            around wicket pages. If
            you can recommend another way to do that , it would be
            helpful as well. I
            did a quick scan through wicket documentation, but
            couldn`t find anything
            useful. Maybe I missed something?

            Време: 21.02.2011. 13:31, Dan Griffin пише:

             Hi all,

                I have guice integrated in my wicket app, and it
                worked fine until I tried
                to inject a page, when I received

                java.lang.IllegalArgumentException: Protected method:
                checkHierarchyChange(Lorg/apache/wicket/Component;)

                Now, I assume this is because of guice integration
                pitfall<
                https://cwiki.apache.org/WICKET/guice-integration-pitfall.html>,
                as I
                clearly cannot use interfaces here, but the proposed
                solution (with
                deprecated protected no-arg constructor) doesn`t help
                me here. Any idea how
                to get around this?

                Thanks in advance,
                Dan








Reply via email to