近日,发现公司的应用经常停止响应,通过监控weblogic 8.16 上的内存使用情况,发现Axis组件的ConfigurationException占据很大的内存分配空间,如下图:

此weblogic上发布了一个使用Axis客户端调用webservice的应用,联系该webservice客户端开发人员无果后,想自己看如何解决这个问题
先下载了axis 1.4的源代码,根据上图监控AxisEngine后标注的行数,找到以下代码
[java]view plaincopyprint?
- // fixme: could someone who knows double-check I've got the semantics of 
 - // this right? 
 - /**
 -  * Get the <code>SOAPService</code> for a particular local name.
 -  *
 -  * @param name the local name of the request type
 -  * @return the <code>SOAPService</code> for this request type
 -  * @throws AxisFault
 -  */
 - public SOAPService getService(String name) throws AxisFault 
 - { 
 -       try { 
 -             return config.getService(new QName(null, name)); 
 -        } catch (ConfigurationException e) { 
 -             try { 
 -                   return config.getServiceByNamespaceURI(name); 
 -              } catch (ConfigurationException e1) { 
 -                   thrownew AxisFault(e); 
 -              } 
 -        } 
 - } 
 
    // fixme: could someone who knows double-check I've got the semantics of
//   this right?
/**
* Get the <code>SOAPService</code> for a particular local name.
*
* @param name  the local name of the request type
* @return      the <code>SOAPService</code> for this request type
* @throws AxisFault
*/
public SOAPService getService(String name) throws AxisFault
{
              try {
                        return config.getService(new QName(null, name));
              } catch (ConfigurationException e) {
                  try {
                            return config.getServiceByNamespaceURI(name);
                  } catch (ConfigurationException e1) {
                      throw new AxisFault(e);
}
}
}
这个代码表面上看起来没什么问题,首先调用getService,如果报错,再调getServiceByNamespaceURI
但是在jrockit环境下却一直占用大量内存分配,直到溢出。检查过日志级别,也处于Info。
将此处代码顺序getServiceByNamespaceURI调至前面,先解决,后续再查看原因。
最近继续阅读Axis源代码,发现初始化AxisServlet已经对server-config.wsdd配置进行实例化至WSDDDeployment中,并由FileProvider引用。FileProvider实际上将getService任务交给deployment完成,deployment在AxisEngine初始化时已经持有server-config.wsdd中各种配置信息,如:transport、handler、globalConfiguration、service,并将各类配置存储至HashMap缓存中。
本例实际上是由于server-config.wsdd中某些接口没有或者配置错误,导致先调用getService不断失败后去尝试getServiceByNamespaceURI大量抛出ConfigurationException,但是此错为何会堆积在内存中不断增长呢?有空还需要继续检查,大家有深入研究过源码的也可以发表一下高见,非常欢迎。