getThreadLocalRequest() is returning Null request

402 views
Skip to first unread message

sim123

unread,
Dec 1, 2008, 8:05:00 PM12/1/08
to Google Web Toolkit
Hello All,

I have one servlet for login, which sets the session id in cookies,
then I have different services to be called after user is logged in. I
have one service which gets user preferences another service which
gets all the products which a user would like to buy etc. When I try
to validate the session against first service (getUserPrefrences) by
this

String sessionId = this.getThreadLocalRequest().getSession().getId();

I get a sessionId do the validation on it and everything works fine,
when I try calling another service (getProducts) getThreadLocalRequest
() returns null request and I get a null pointer exception. Can
someone please help me with this.

Thanks for all the help and support.

eastgate

unread,
Dec 1, 2008, 9:46:28 PM12/1/08
to Google Web Toolkit
what RPC servlet class you derive?
directly use com.google.gwt.user.server.rpc.RemoteServiceServlet or
others 3rd party rpc servlet like HibernateRemoteService(from
Hibernate4GWT) or gwt-sl ?

if you using RemoteServiceServlet, it should get result.

Lothar Kimmeringer

unread,
Dec 2, 2008, 3:39:08 AM12/2/08
to Google-We...@googlegroups.com
sim123 schrieb:

> When I try
> to validate the session against first service (getUserPrefrences) by
> this
>
> String sessionId = this.getThreadLocalRequest().getSession().getId();
>
> I get a sessionId do the validation on it and everything works fine,
> when I try calling another service (getProducts) getThreadLocalRequest
> () returns null request and I get a null pointer exception. Can
> someone please help me with this.

Do you call getProducts inside an overwritten doPost-method or an
implemented doGet-method()? When doing this, the part of the code
of the RemoteServiceServlet, that is setting the member returned
by getThreadLocalRequest is not executed, so you get null, if you
try to call it that way.

If I'm wrong, some small source how your code looks like where
you have the problem might help, otherwise only guessing is
possible.


Regards, Lothar

Reply all
Reply to author
Forward
0 new messages