You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nial Darbey <ni...@gmail.com> on 2009/08/20 12:09:00 UTC

Nial Darbey: ClassCast exception when invoking MySession.get() from Maven test phase

Hi everyone,I have subclassed the WebSession class as recommended in Wicket
in Action and I override the public static get() method to return
Session.get() cast to MyWebSession as follows:
public static MyWebSession get() { return (MyWebSession) Session.get(); }

This of course works as expected but when I run my tests from maven against
code which uses this I get a ClassCastException
(org.apache.wicket.protocol.http.WebSession cannot be cast to
org.my.MyWebSession)
I'm guessing this must be a classloader issue.
Has anyone come across this?
Best regards,
Nial Darbey

Re: Nial Darbey: ClassCast exception when invoking MySession.get() from Maven test phase

Posted by Witold Czaplewski <wi...@cts-media.eu>.
Try

    public static MyWebSession get() {
        return (MyWebSession) WebSession.get();
    }

Witold

Am Thu, 20 Aug 2009 12:09:00 +0200
schrieb Nial Darbey <ni...@gmail.com>:

> Hi everyone,I have subclassed the WebSession class as recommended in
> Wicket in Action and I override the public static get() method to
> return Session.get() cast to MyWebSession as follows:
> public static MyWebSession get() { return (MyWebSession)
> Session.get(); }
> 
> This of course works as expected but when I run my tests from maven
> against code which uses this I get a ClassCastException
> (org.apache.wicket.protocol.http.WebSession cannot be cast to
> org.my.MyWebSession)
> I'm guessing this must be a classloader issue.
> Has anyone come across this?
> Best regards,
> Nial Darbey


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Nial Darbey: ClassCast exception when invoking MySession.get() from Maven test phase

Posted by Nial Darbey <ni...@gmail.com>.
Igor,thanks for that. Yes, the solution was in passing the DummyApplication
to the WicketTester constructor.
Nial

2009/8/20 Igor Vaynberg <ig...@gmail.com>

> are you making wicket tester instantiate your own application class?
>
> -igor
>
> On Thu, Aug 20, 2009 at 3:09 AM, Nial Darbey<ni...@gmail.com> wrote:
> > Hi everyone,I have subclassed the WebSession class as recommended in
> Wicket
> > in Action and I override the public static get() method to return
> > Session.get() cast to MyWebSession as follows:
> > public static MyWebSession get() { return (MyWebSession) Session.get(); }
> >
> > This of course works as expected but when I run my tests from maven
> against
> > code which uses this I get a ClassCastException
> > (org.apache.wicket.protocol.http.WebSession cannot be cast to
> > org.my.MyWebSession)
> > I'm guessing this must be a classloader issue.
> > Has anyone come across this?
> > Best regards,
> > Nial Darbey
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Nial Darbey: ClassCast exception when invoking MySession.get() from Maven test phase

Posted by Igor Vaynberg <ig...@gmail.com>.
are you making wicket tester instantiate your own application class?

-igor

On Thu, Aug 20, 2009 at 3:09 AM, Nial Darbey<ni...@gmail.com> wrote:
> Hi everyone,I have subclassed the WebSession class as recommended in Wicket
> in Action and I override the public static get() method to return
> Session.get() cast to MyWebSession as follows:
> public static MyWebSession get() { return (MyWebSession) Session.get(); }
>
> This of course works as expected but when I run my tests from maven against
> code which uses this I get a ClassCastException
> (org.apache.wicket.protocol.http.WebSession cannot be cast to
> org.my.MyWebSession)
> I'm guessing this must be a classloader issue.
> Has anyone come across this?
> Best regards,
> Nial Darbey
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org