Yeah, this with the final classes was something I also wanted to tell you
:-) But cool if we can workaround it that way!

Kind regards,
Andreas

2011/8/25 Łukasz Dywicki <[email protected]>

> Hey :),
> I enabled serialization hints in JVM (
> http://stackoverflow.com/questions/627389/locating-serialization-issue-in-complex-bean)
> and now it is clear why do we have NotSerializableExceptions.
>
> Every time when we declare some variable as final and use it in anonymous
> class it is managed by JVM, not by Wicket, for example:
>
> final Configuration configuration = new ConfigurationModel(pid,
> configurationAdmin).getObject();
> MapEditForm<String, String> mapEditForm = new MapEditForm<String,
> String>("edit", formModel) {
>    @Override
>    protected void onSubmit() {
>        Map<String, String> map = getModelObject();
>        configuration.update(DictionaryUtils.dictionary(map));
>    }
> };
>
> The debug output:
> Caused by: java.io.NotSerializableException:
> org.apache.felix.cm.impl.ConfigurationAdapter
>        - field (class
> "org.apache.karaf.webconsole.osgi.internal.configuration.ConfigurationEditPage$1",
> name: "val$configuration", type: "interface
> org.osgi.service.cm.Configuration")
>        - object (class
> "org.apache.karaf.webconsole.osgi.internal.configuration.ConfigurationEditPage$1",
> [MarkupContainer [Component id = edit]])
>        - element of array (index: 7)
>        - array (class "[Ljava.lang.Object;", size: 9)
>        - field (class "org.apache.wicket.MarkupContainer", name:
> "children", type: "class java.lang.Object")
>        - root object (class
> "org.apache.karaf.webconsole.osgi.internal.configuration.ConfigurationEditPage"
>
> As you see an instance of org.osgi.service.cm.Configuration comes from our
> PageClass, not from wicket. I going to fix all usage of these final objects.
> Also we might introduce LoadableDetachableModels for pages, with these we
> still may use objecs in inner classes managed by wicket.
>
> Best regards,
> Lukasz
>
> > Thanks for the update Andreas.
> >
> > Regards
> > JB
> >
> > On 08/25/2011 06:05 AM, Andreas Pieber wrote:
> >> Hey guys,
> >>
> >> I'm currently hunting down one Not Serializable Exception (NSE) after
> the
> >> other in PW. Currently I wasn't able to find any problems with PW but
> >> instead how LoadableDetachable Model (LDM) is used. Just to make this
> clear:
> >>
> >> Let's call a not serialisable object NSO. If you do something like
> >>
> >> new LoadableDetachableModel<NSO>(...) {
> >> ...
> >> NSO x = generateNSOFromSomewhere();
> >> return x;
> >> ...
> >> }
> >>
> >> this will still fail to serialize. The LDMs purpose is to transform the
> NSO
> >> to something which could be serialized (SO). So, LDM have to be used in
> the
> >> following way instead:
> >>
> >> new LoadableDetachableModel<SO>(...) {
> >> ...
> >> NSO x = generateNSOFromSomewhere();
> >> SO y = convertNSOtoSO(x);
> >> return y;
> >> ...
> >> }
> >>
> >> I know that everything still seams to work (although of those NSE), it
> is
> >> not very pretty/good if we plaster the entire log file with those
> >> exceptions.
> >>
> >> Hope this helps.
> >>
> >> Kind regards,
> >> Andreas
> >>
> >
> > --
> > Jean-Baptiste Onofré
> > [email protected]
> > http://blog.nanthrax.net
> > Talend - http://www.talend.com
>
>

Reply via email to