axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From April Easton <>
Subject [Axis2] - Migrating axis to axis2 and lost servletContext
Date Tue, 07 Jun 2011 22:11:45 GMT
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 destroyThread.");

            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,

View raw message