Re: Application not seri

2019-12-21 Thread Ernesto Reinaldo Barreiro
By the way: your avatar made me remember good times sitting together with
my boy watching adventure times :-)

On Sat, Dec 21, 2019 at 9:03 AM ShengChe Hsiao  wrote:

> Dear all
> I faced a strange exception, the error message:
>
> A problem occurred while checking object with type:
> info.sls.WicketApplication
>
> Field hierarchy is:
>
>   1 [class=info.sls.MapPage, path=1]
>
> private java.lang.Object org.apache.wicket.MarkupContainer.children
> [class=java.util.ArrayList]
>
>   private java.lang.Object
> org.apache.wicket.MarkupContainer.children[write:27][write:28]
> [class=org.apache.wicket.markup.html.form.StatelessForm,
> path=1:formGMapSelect]
>
> private java.lang.Object org.apache.wicket.MarkupContainer.children
> [class=java.util.ArrayList]
>
>   private final java.lang.String
>
> org.apache.wicket.markup.html.form.ChoiceRenderer.idExpression[write:8][write:11]
> [class=org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink,
> path=1:formGMapSelect:btnSelect]
>
> final info.sls.GMapPanel info.sls.MapPage$1.val$gMapPanel
> [class=info.sls.GMapPanel, path=1:gmaps]
>
>   java.lang.Object org.apache.wicket.Component.data
> [class=[Ljava.lang.Object;]
>
> java.lang.Object org.apache.wicket.Component.data[0]
> [class=org.apache.wicket.model.LoadableDetachableModel]
>
>   final info.sls.WicketApplication
> info.sls.WicketApplication$3.this$0 [class=info.sls.WicketApplication]
> <- field that is causing the problem
>
>
> I use transient with WicketApplication in my BasePage, but the issue
> continued.
>
>
> private transient WicketApplication wicketApplication;
>
>
>
> Any suggestions?
> 
> --->
> To boldly go where no man has gone before.
> 
> --->
> We do this not because it is easy. We do this because it is hard.
> -
> -->
> If I have seen further it is by standing on the shoulders of giants.
> --
> ->
> front...@gmail.com
>
> ->
>


-- 
Regards - Ernesto Reinaldo Barreiro


Re: Application not seri

2019-12-21 Thread Ernesto Reinaldo Barreiro
Hi,

Instead of keeping a reference to WebApplication just use
Application.get();: it is bound to thread as a threadlocal. If you need
your specific instance you can always add

public static MyWebApplication getInstance() {
  return (MyWebApplication) Application.get();
}

to class MyWebApplication, This way you can always
call MyWebApplication.getInstance() and you don't need to keep a
reference to it as a field on base page.


On Sat, Dec 21, 2019 at 9:03 AM ShengChe Hsiao  wrote:

> Dear all
> I faced a strange exception, the error message:
>
> A problem occurred while checking object with type:
> info.sls.WicketApplication
>
> Field hierarchy is:
>
>   1 [class=info.sls.MapPage, path=1]
>
> private java.lang.Object org.apache.wicket.MarkupContainer.children
> [class=java.util.ArrayList]
>
>   private java.lang.Object
> org.apache.wicket.MarkupContainer.children[write:27][write:28]
> [class=org.apache.wicket.markup.html.form.StatelessForm,
> path=1:formGMapSelect]
>
> private java.lang.Object org.apache.wicket.MarkupContainer.children
> [class=java.util.ArrayList]
>
>   private final java.lang.String
>
> org.apache.wicket.markup.html.form.ChoiceRenderer.idExpression[write:8][write:11]
> [class=org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink,
> path=1:formGMapSelect:btnSelect]
>
> final info.sls.GMapPanel info.sls.MapPage$1.val$gMapPanel
> [class=info.sls.GMapPanel, path=1:gmaps]
>
>   java.lang.Object org.apache.wicket.Component.data
> [class=[Ljava.lang.Object;]
>
> java.lang.Object org.apache.wicket.Component.data[0]
> [class=org.apache.wicket.model.LoadableDetachableModel]
>
>   final info.sls.WicketApplication
> info.sls.WicketApplication$3.this$0 [class=info.sls.WicketApplication]
> <- field that is causing the problem
>
>
> I use transient with WicketApplication in my BasePage, but the issue
> continued.
>
>
> private transient WicketApplication wicketApplication;
>
>
>
> Any suggestions?
> 
> --->
> To boldly go where no man has gone before.
> 
> --->
> We do this not because it is easy. We do this because it is hard.
> -
> -->
> If I have seen further it is by standing on the shoulders of giants.
> --
> ->
> front...@gmail.com
>
> ->
>


-- 
Regards - Ernesto Reinaldo Barreiro


Re: Application not seri

2019-12-21 Thread Bas Gooren
Hi,

The stacktrace shows you that you are passing a LoadableDetachableModel
to info.sls.GMapPanel which contains a non-serializable reference
to info.sls.WicketApplication$3;

info.sls.WicketApplication$3 is an anonymous class inside your
WicketApplication, which contains a reference to it’s owning class
(WicketApplication).

Can you show us the code where you initialize the GMapsPanel and it’s
LoadableDetachableModel? That’s where we’ll probably find the culprit :-)

Usually this is caused by code like this:

MyServiceInsideApplication service = MyApplication.getService();
LoadableDetachableModel ldm = new LoadableDetachableModel() {
X load() {
return service.getX();
}
};

The above code will attempt to serialize MyServiceInsideApplication.

Code like this should be rewritten as follows:

LoadableDetachableModel ldm = new LoadableDetachableModel() {
X load() {
MyServiceInsideApplication service = MyApplication.getService();
return service.getX();
}
};

This way, there is no need to serialize the service, as it can be looked up
just-in-time when it is needed.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 21 december 2019 bij 07:03:18, ShengChe Hsiao (front...@gmail.com)
schreef:

Dear all
I faced a strange exception, the error message:

A problem occurred while checking object with type:
info.sls.WicketApplication

Field hierarchy is:

1 [class=info.sls.MapPage, path=1]

private java.lang.Object org.apache.wicket.MarkupContainer.children
[class=java.util.ArrayList]

private java.lang.Object
org.apache.wicket.MarkupContainer.children[write:27][write:28]
[class=org.apache.wicket.markup.html.form.StatelessForm,
path=1:formGMapSelect]

private java.lang.Object org.apache.wicket.MarkupContainer.children
[class=java.util.ArrayList]

private final java.lang.String
org.apache.wicket.markup.html.form.ChoiceRenderer.idExpression[write:8][write:11]

[class=org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink,
path=1:formGMapSelect:btnSelect]

final info.sls.GMapPanel info.sls.MapPage$1.val$gMapPanel
[class=info.sls.GMapPanel, path=1:gmaps]

java.lang.Object org.apache.wicket.Component.data
[class=[Ljava.lang.Object;]

java.lang.Object org.apache.wicket.Component.data[0]
[class=org.apache.wicket.model.LoadableDetachableModel]

final info.sls.WicketApplication
info.sls.WicketApplication$3.this$0 [class=info.sls.WicketApplication]
<- field that is causing the problem


I use transient with WicketApplication in my BasePage, but the issue
continued.


private transient WicketApplication wicketApplication;



Any suggestions?

--->
To boldly go where no man has gone before.

--->
We do this not because it is easy. We do this because it is hard.
-
-->
If I have seen further it is by standing on the shoulders of giants.
--
->
front...@gmail.com
->