axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From April Easton <>
Subject RE: AW: [Axis2] - Migrating axis to axis2 and lost servletContext
Date Thu, 09 Jun 2011 20:36:58 GMT
I have updated my service to implement LifeCycle.  I can now see in my logs where the init(serviceContext)
and destroy(serviceContext) is being called. I will continue from here to stop my threads.
 Thank you for the good reading material.

Deepal - The "Axis2 Deployment model" article did not come up when I clicked on it, instead
I got the website's main page, just thought I'd let you know.


-----Original Message-----
From: April Easton [] 
Sent: Thursday, June 09, 2011 11:02 AM
Subject: RE: AW: [Axis2] - Migrating axis to axis2 and lost servletContext

My service is POJO and it does not extend anything.  The init() method is called from the
instantiation of the class. Our service scope is application because we need these threads
to start when axis2 starts up and die when axis2 dies. 

I've read many of the links that Depal gave to me.  I learned several things.  I have downloaded
and am testing with YourKit to see what I can learn from that application. 

What is a good way to stop these threads in axis2?  It seems that how we were doing it in
axis, does not work now.


From: Tony HEDOUX [] 
Sent: Thursday, June 09, 2011 6:38 AM
Subject: RE: AW: [Axis2] - Migrating axis to axis2 and lost servletContext


I don't understand all your issue, but about the message context null, there is an easy way
to get access to Servlet context of Axis2 :

In your AxisService class, in 

init(ServiceContext sc){
ServletContext sc = (ServletContext) sc.getConfigurationContext().getProperty("transport.http.servletContext");

Then, you should be able to store/read your thread in this context and stop it if necessary.

Subject: AW: [Axis2] - Migrating axis to axis2 and lost servletContext
Date: Thu, 9 Jun 2011 11:19:32 +0200
But in scope="soapsession" I have to define a time-out to get long-lasting-sessions and a
state-full-object. If the time-out hits before the next request is made by the session-thread,
my service-object (instance-of-the-service-class) (addressed by the servicegroupId), does
no longer exists. And as we have our time-out set to about 8hours, real long lasting sessions,
the time-out is only hit after 8h. Hence the destroy() method called when the same service-class
gets a request then triggers only the destroy-method after 8h, when the service-object timed-out
for this-service-object is occurred. We do normally not see the destroy() method being called.
This time-out is a very annoying issue in fact! If we would be able to set this time-out programmatically
by something like a prepare-to-stop-call(), to let's say 5 seconds, then we could observe
how our destroy() method gets called. So initiating threads in the init() method is OK. Keeping
threads for a long time is a different issue in scope="soapsession", and the time-out-facility
makes the thing not better. Or does somebody know a way how I can call to destruct my service-providing-object,
and prove that the destroy() method is then called?
Von: Deepal Jayasinghe [] 
Gesendet: Mittwoch, 8. Juni 2011 01:23
Betreff: Re: [Axis2] - Migrating axis to axis2 and lost servletContext
In Axis2 it has four different type of sessions and transport session is one of them. So,
you have access to the serveltContext only if you use the transport session.

You can deploy the service in any scope and create the threads inside the init method and
write the code to stop them inside the destroy method. When the session complete, Axis2 automatically
calls the destroy method and invoke your code. One thing you need to keep in mind is the number
of services instances, in Axis2 for each new session it creates a new service impl class.
And also use the following reference:


On 6/7/2011 6:11 PM, April Easton wrote: 
Good day,
     I have almost successfully converted our axis service to an axis2 service.  It all
works, except stopping the threads that are created by this service.  With axis, we used
the ServletContextListener destroy method to access the ServletContext.getAttribute("AxisServiceInstance")
that was written in AxisService and then call the stopThread() method.  I have been having
great difficulties in converting this small piece of the project.  I have tried to get the
MessageContext in AxisService and write the ServletContext.setAttribute("AxisServiceInstance"). 
The MessageContext is always null.  I have placed this Listener in axis2/WEB-INF/lib.  The
posts that I've been reading make this look so easy.  What am I overlooking?  Here is a
snapshot of my code.
public class AxisListener implements ServletContextListener {
      public void contextInitialized(ServletContextEvent event){
            System.out.println(this.getClass().getName() + ":contextInitialized:context
is " + event.getServletContext().getRealPath(""));
      public void contextDestroyed(ServletContextEvent event) {
            System.out.println(this.getClass().getName() + ":contextDestroyed:before
            AxisService axisService = (AxisService) event.getServletContext().getAttribute("AxisServiceInstance");
}     //ServletContextListener
public class AxisService {    
      public AxisService() {
      private void init(){
            //This is the best that I've found using the posts to date: 
            //set Attributes to be used by AxisListener#contextDestroyed(ServletContextEvent
       MessageContext msgContext = MessageContext.getCurrentMessageContext();
            log.debug(this.getClass().getName() + ":init:messageContext:" + msgContext);     
//This is Always null   
            //Here is what it was:
            //set Attributes to be used by AxisListener#contextDestroyed(ServletContextEvent
            MessageContext msgContext= MessageContext.getCurrentContext();
Thank you,

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message