HttpSession session = getThreadLocalRequest().getSession() Null Pointer Exception

773 views
Skip to first unread message

KenJi_getpowered

unread,
Jun 8, 2010, 5:05:40 AM6/8/10
to Google Web Toolkit
Hello every body,

I can't figure out why there is a Null Pointer Exception here.

I am trying to share informations through sessions within my
application. I have a regular servlet that sets the session and insert
a login. then I wanted to retrieve that login into a
RemoteServiceServlet with that instruction :
HttpSession session = getThreadLocalRequest().getSession();

but as I said it gives me a NPE. What is wrong?
Also I can't find any good documentation on working with sessions with
GWT.

Do you have any solution? or at least explanation?

olivier nouguier

unread,
Jun 8, 2010, 2:14:53 PM6/8/10
to google-we...@googlegroups.com
Hi,
 the getThreadLocalRequest() as it sound returns the request stored *during* the request/response in a ThreadLocal. So if it return null it's because it is not the same thread ;)
 


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
"Computers are useless. They can only give you answers."
- Pablo Picasso -

KenJi_getpowered

unread,
Jun 9, 2010, 7:37:57 AM6/9/10
to Google Web Toolkit
As a matter of fact, I resolved it.

The getThreadLocalRequest() return null when called into the
constructor of the 1st RemoteServiceServlet called.

What can be disturbing is :
- It returns null even if the session is already initialized by a
classic servlet
- It is not returning null when called in the constructors of a 2nd
RemoteServiceServlet.

If it can help !

On 8 juin, 20:14, olivier nouguier <olivier.nougu...@gmail.com> wrote:
> Hi,
>  the getThreadLocalRequest() as it sound returns the request stored *during*
> the request/response in a ThreadLocal. So if it return null it's because it
> is not the same thread ;)
>
> On Tue, Jun 8, 2010 at 11:05 AM, KenJi_getpowered <mikael.k...@gmail.com>wrote:
>
>
>
> > Hello every body,
>
> > I can't figure out why there is a Null Pointer Exception here.
>
> > I am trying to share informations through sessions within my
> > application. I have a regular servlet that sets the session and insert
> > a login. then I wanted to retrieve that login into a
> > RemoteServiceServlet with that instruction :
> > HttpSession session = getThreadLocalRequest().getSession();
>
> > but as I said it gives me a NPE.  What is wrong?
> > Also I can't find any good documentation on working with sessions with
> > GWT.
>
> > Do you have any solution? or at least explanation?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages