All,

I just ran into an unpleasant surprise. I had a Wicket page working nicely. The page keeps a state of ExampleValue objects in a map. Those instance have members of type File, which as you know are serializable. I wanted to upgrade the class in support the new Java NIO Path (which is much nicer than File). As soon as I did, I got this Wicket error:

2014-09-06 16:08:22 ERROR (JavaSerializer) [2014-09-06 16:08:22,433] - org.apache.wicket.serialize.java.JavaSerializer.serialize(JavaSerializer.java:95): Error serializing object class com.example.ExamplePage [object=[Page class = com.example.ExamplePage, id = 4, render count = 7]] org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream$ObjectCheckException: The object type is not Serializable!
A problem occurred while checking object with type: sun.nio.fs.WindowsPath
Field hierarchy is:
  4 [class=com.example.ExamplePage, path=4]
private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[4] [class=org.apache.wicket.markup.html.form.Form, path=4:form] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private java.lang.Object org.apache.wicket.MarkupContainer.children[3] [class=org.apache.wicket.markup.repeater.data.DataView, path=4:form:ExampleValue] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=org.apache.wicket.markup.repeater.Item, path=4:form:ExampleValue:6] java.lang.Object org.apache.wicket.Component.data [class=org.apache.wicket.model.Model] private java.io.Serializable org.apache.wicket.model.Model.object [class=com.example.ExamplePage$ExampleValue] private final java.nio.file.Path com.example.ExamplePage$ExampleValue.path [class=sun.nio.fs.WindowsPath] <----- field that is causing the problem

Yes, I could write a lot of custom serialization code to save and load sun.nio.fs.WindowsPath, but it's a shame such a common (and future-oriented) class can't be used in Wicket pages. Any way Wicket could work around this?

Garret

Reply via email to