You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Juha Kononen <Ju...@savonia-amk.fi> on 2005/08/16 13:03:12 UTC
The static MessageContext.getCurrentContext method doesn't
work
Hi, I have a problem with using the MessageContext.getCurrentContext
method in my server-side code.
I would like to get the current context to able to get an access to the
current session. Well, everything works just fine if I use the
getCurrentContext method in one of my own objects, but something strange
happends when I'm trying to use this method inside a thread. Everytime I
call the MessageContext.getCurrentContext method in a thread it returns
only null. Is this a bug? As I told, the the
MessageContext.getCurrentContext method works great, I can get my
MessageContext object, if I don't use the method in threads. Have you
guys got this method working in threads? Even if I can pass a
MessageContext reference into a thread via a static variable the
getCurrentContext doesn't work. There's got to be something wrong with
this method. Because of this problem it's impossible to make use of the
session mechanism in threads.
I'm working at the moment on a project where we are developing a
decision support system. The system runs on Tomcat 5.5.9 and uses the
Axis 1.2.1 Final version. I would be very grateful for any help.
Juha Kononen
e-mail: Juha.Kononen@savonia-amk.fi
Re: The static MessageContext.getCurrentContext method doesn'twork
Posted by Jeff Greif <jg...@alumni.princeton.edu>.
The message context returned from this method is held in a thread-local
variable of the thread handling the web service request. This is the way a
static method can be used to return a message context correctly for
simultaneously-handled web service requests of various kinds. However, it
only works in the request-handling threads (i.e., the ones in which the
implementation method of the web service operation is called).
Jeff
----- Original Message -----
From: Juha Kononen
To: axis-user@ws.apache.org
Sent: Tuesday, August 16, 2005 4:03 AM
Subject: The static MessageContext.getCurrentContext method doesn'twork
Hi, I have a problem with using the MessageContext.getCurrentContext method
in my server-side code.
I would like to get the current context to able to get an access to the
current session. Well, everything works just fine if I use the
getCurrentContext method in one of my own objects, but something strange
happends when I'm trying to use this method inside a thread. Everytime I
call the MessageContext.getCurrentContext method in a thread it returns only
null. Is this a bug? As I told, the the MessageContext.getCurrentContext
method works great, I can get my MessageContext object, if I don't use the
method in threads. Have you guys got this method working in threads? Even if
I can pass a MessageContext reference into a thread via a static variable
the getCurrentContext doesn't work. There's got to be something wrong with
this method. Because of this problem it's impossible to make use of the
session mechanism in threads.