For what it's worth ... I use Guice injection across the entire codebase.

Pages get Services
Services get Daos
Daos get connections ... etc

I even inject utility classes as needed and can't say I've had any problems.

-Luther



On Wed, Jun 24, 2009 at 11:38 AM, Aaron Dixon <atdi...@gmail.com> wrote:

> Hello, all -
>
> Guice/Wicket integration is excellent, but doesn't seem to work properly
> when I use @Inject-ed services on my *page* classes. It only seems to work
> when I inject services on components of my pages. I get
> WicketNotSerializableExceptions for services that I inject on my page class
> instances.
>
> So, if this is my page class:
>
> ====
>
> public class MyPage extends WebPage {
>
>    @Inject
>   private MyDao myDao; // causes WicketNotSerializableException
>
>   public MyPage() {
>       add(new MyPanel() {
>           @Inject
>           private MyDao myDao; // works fine and dandy
>           ...
>       }
>   }
> }
>
> ====
>
> I get:
>
> ====
>
>
> org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException:
> Unable to serialize class:
> com.mycompany.dao.MyDao$$EnhancerByGuice$$3e6e9f94
> Field hierarchy is:
>  2 [class=com.mycompany.pages.MyPage, path=2]
>    private com.mycompany.dao.MyDao
>
> com.mycompany.pages.MyPage.myDao[class=com.mycompany.dao.MyDao$$EnhancerByGuice$$3e6e9f94]
> <----- field that is not serializable
>    at
>
> org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:342)
>    at
>
> org.apache.wicket.util.io.SerializableChecker.checkFields(SerializableChecker.java:610)
> ...
> ====
>
> Has anyone else noticed this?
>

Reply via email to