SessionAttribute and SessionState is null in onValidate method

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SessionAttribute and SessionState is null in onValidate method

Ric 2000
Dear Tapestry users,

I face the following problem:
In a page I use a simple bean annotated as SessionState or SessionAttribute
(problem is the same on both).
It is initialized in the SetupRender method of the page and in other
methods, called from within the SetupRender method, the object is in
correct sttae and shows the expected values.
But after a form submit triggered in this page, the SessionState or
SessionAttribute object is suddenly "null" in the onValidate method of this
form.
How did I see that?
The production mode flag is "false", so that I can debug the Tapestry
managed objects. When the onValidate method is entered, the SessionState or
SessionAttributehas still the expeceted state: it is not null and all
properties in it are correctly filled.
But when the object is "touched" the first time by calling a property
getter or setter on it, it is directly "null" and an NPE is thrown when
accessing it.

The framework version is 5.4.3

Do you have any explanations for that? Thanks in advance for your hints!

Regards, Ric
Reply | Threaded
Open this post in threaded view
|

Re: SessionAttribute and SessionState is null in onValidate method

Cezary Biernacki
Hi Ric,

I suspect that a server-side session is not established for some reason,
e.g. the browser does not send back the JSESSIONID cookie or something
invalidates the session. It is hard to tell without any source code
examples. You can try verify what is happening by putting breakpoints in
relevant parts of Tapestry. For example, if you use "@SessionAttribute",
find the SessionAttributeWorker in Tapesty
(package: org.apache.tapestry5.internal.transform), and set a breakpoint at
the beginning of the "get()" method of SessionKeyConduit.

Best regards,
Cezary


On Tue, Jun 18, 2019 at 8:23 PM Ric 2000 <[hidden email]> wrote:

> Dear Tapestry users,
>
> I face the following problem:
> In a page I use a simple bean annotated as SessionState or SessionAttribute
> (problem is the same on both).
> It is initialized in the SetupRender method of the page and in other
> methods, called from within the SetupRender method, the object is in
> correct sttae and shows the expected values.
> But after a form submit triggered in this page, the SessionState or
> SessionAttribute object is suddenly "null" in the onValidate method of this
> form.
> How did I see that?
> The production mode flag is "false", so that I can debug the Tapestry
> managed objects. When the onValidate method is entered, the SessionState or
> SessionAttributehas still the expeceted state: it is not null and all
> properties in it are correctly filled.
> But when the object is "touched" the first time by calling a property
> getter or setter on it, it is directly "null" and an NPE is thrown when
> accessing it.
>
> The framework version is 5.4.3
>
> Do you have any explanations for that? Thanks in advance for your hints!
>
> Regards, Ric
>
Reply | Threaded
Open this post in threaded view
|

Re: SessionAttribute and SessionState is null in onValidate method

Ric 2000
Hi Cezary,
first thanks!
I provided no code, because it is rather straight forward, just an
@SessionAttribute annotated private field, which is a bean implementing
Serializable.
Then this @SetupRender method constructing the bean and filling it's
properties, a form and an onValidate and an onSuccess method. And as I
mentioned the SessionAttribut bean is already in the onValidate methode
null, very strange.
But I will follow your hints and try to figure out whats going on :-)

Regards, Ric

On Tue, Jun 18, 2019 at 9:10 PM Cezary Biernacki <[hidden email]>
wrote:

> Hi Ric,
>
> I suspect that a server-side session is not established for some reason,
> e.g. the browser does not send back the JSESSIONID cookie or something
> invalidates the session. It is hard to tell without any source code
> examples. You can try verify what is happening by putting breakpoints in
> relevant parts of Tapestry. For example, if you use "@SessionAttribute",
> find the SessionAttributeWorker in Tapesty
> (package: org.apache.tapestry5.internal.transform), and set a breakpoint at
> the beginning of the "get()" method of SessionKeyConduit.
>
> Best regards,
> Cezary
>
>
> On Tue, Jun 18, 2019 at 8:23 PM Ric 2000 <[hidden email]> wrote:
>
> > Dear Tapestry users,
> >
> > I face the following problem:
> > In a page I use a simple bean annotated as SessionState or
> SessionAttribute
> > (problem is the same on both).
> > It is initialized in the SetupRender method of the page and in other
> > methods, called from within the SetupRender method, the object is in
> > correct sttae and shows the expected values.
> > But after a form submit triggered in this page, the SessionState or
> > SessionAttribute object is suddenly "null" in the onValidate method of
> this
> > form.
> > How did I see that?
> > The production mode flag is "false", so that I can debug the Tapestry
> > managed objects. When the onValidate method is entered, the SessionState
> or
> > SessionAttributehas still the expeceted state: it is not null and all
> > properties in it are correctly filled.
> > But when the object is "touched" the first time by calling a property
> > getter or setter on it, it is directly "null" and an NPE is thrown when
> > accessing it.
> >
> > The framework version is 5.4.3
> >
> > Do you have any explanations for that? Thanks in advance for your hints!
> >
> > Regards, Ric
> >
>