I got the same error today, seems totally random.
The only possible explanation I have is that maybe the subclass (LoginPage$1 in your case) stores a PageHolder class instead of the actual page (LoginPage) when serialized, and when LoginPage$1 is deserialized, the PageHolder retrieves/points to a different Page.
I was just as baffled as you since in my case the two classes were totally different, like in your case (com.application.MainPage vs wicket.quickstart.LoginPage).
In my case it's two pages from the same application, but they are functionally separate and never interact.
In my case I made the inner class that caused the problem a static inner class. Since I have been unable to reproduce the problem I cannot confirm if this resolves the problem.
Can you share what kind of class LoginPage$1 is? (it's the first anonymous inner class in LoginPage) Is it a class which extends IModel?
Also, you someone from the Wicket team confirm if my explanation above is possible at all (PageHolder retrieving a different class when deserializing)?
Bas
MartinM wrote:
Anybody know what is this situation? Wicket 1.4-rc4
From production:
2009-05-18 16:32:44,316 19598423 [btpool0-112] ERROR RequestCycle -
cannot assign instance of com.application.MainPage to field
wicket.quickstart.LoginPage$1.this$0 of type
wicket.quickstart.LoginPage in instance of
wicket.quickstart.LoginPage$1
java.lang.ClassCastException: cannot assign instance of
com.application.MainPage to field wicket.quickstart.LoginPage$1.this$0
of type wicket.quickstart.LoginPage in instance of
wicket.quickstart.LoginPage$1
at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2032)
at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1212)
.. etc ...