Axis2 1.4.1客户端内存溢出实验

更新时间:2023-11-08 20:51:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

Axis 1.4.1客户端内存溢出实验

实验一:

1. 下载Axis2 1.4.1

http://archive.apache.org/dist/ws/axis2/1_4_1/axis2-1.4.1-bin.zip

2. 新建axis2工程,并导入jar、modules、axis2.xml,目录结构如下:

3. 编写服务类MyService.java package service; public class MyService { public String getGreeting(String name) { return \您好 \ } public void update(String data) { System.out.println(\已经更新\ } } 4. 新建文件\\services\\TestService\\META-INF\\services.xml Web Service 5. 发布应用,访问http://127.0.0.1:8080/axis2/services/myService?wsdl

6. 通过运行下面bat,生成客户端代码 @echo off @rem 这个地方定义了JAVA路径 if not \set JAVA_HOME=D:\\jdk1.6.0 :okAxis2 @rem 这个地方定义了AXIS2的路径 if not \set AXIS2_HOME=E:\\axis2-1.4.1 :okWsdl @rem 这个地方定义了WSDL文件的名称 set wsdlinfo=\/services/myService?wsdl\ if exist \ :okHome rem set the classes setlocal EnableDelayedExpansion rem loop through the libs and add them to the class path set AXIS2_CLASS_PATH=%AXIS2_HOME% FOR %%c in (\AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c rem ----- Execute The Requested Command --------------------------------------- echo Using AXIS2_HOME: %AXIS2_HOME% echo Using JAVA_HOME: %JAVA_HOME% set _RUNJAVA=\%_RUNJAVA% %JAVA_OPTS% -cp \-uri !wsdlinfo!

7. 将生成的客户端java放到axis2工程下面,并修改包路径,如下图所示。

8. 编写客户端调用类MyServiceClient.java package client; import client.MyServiceStub.GetGreeting; import client.MyServiceStub.GetGreetingResponse; public class MyServiceClient { public static void main(String args[]){ try { while(true){ MyServiceStub GetGreeting getGreeting = new GetGreeting(); getGreeting.setName(\ GetGreetingResponse response = my.getGreeting(getGreeting); System.out.println(response.get_return()); my.cleanup(); } my = new MyServiceStub(\/services/myService\ } } } catch (Exception e) { e.printStackTrace(); } 9. 运行MyServiceClient.java

10. 通过jdk自带jconsole监测内存使用情况,发现内存使用率逐渐升高,直到内存溢出。

抛出错误异常信息如下:

Exception in thread \ at edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap$HashEntry.newArray(ConcurrentHashMap.java:207) at edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap$Segment.(ConcurrentHashMap.java:293) at edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap.(ConcurrentHashMap.java:614) at edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap.(ConcurrentHashMap.java:653) at org.apache.axis2.description.AxisDescription.(AxisDescription.java:78) at org.apache.axis2.description.AxisBindingMessage.(AxisBindingMessage.java:89) at org.apache.axis2.deployment.util.Utils.populateBindingOperation(Utils.java:1485) at org.apache.axis2.deployment.util.Utils.populateHttpEndpoint(Utils.java:1465) at org.apache.axis2.deployment.util.Utils.addEndpointsToService(Utils.java:1210) at org.apache.axis2.engine.AxisConfiguration.processEndpoints(AxisConfiguration.java:1249)

at org.apache.axis2.engine.AxisConfiguration.addServiceGroup(AxisConfiguration.java:329) at org.apache.axis2.engine.AxisConfiguration.addService(AxisConfiguration.java:293) at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:175) at org.apache.axis2.client.ServiceClient.(ServiceClient.java:143) space Exception in thread \TCP Connection(idle)\java.lang.OutOfMemoryError: Java heap space Exception in thread \TCP Connection(idle)\java.lang.OutOfMemoryError: Java heap space Exception in thread \TCP Connection(idle)\java.lang.OutOfMemoryError: Java heap space Exception in thread \TCP Connection(idle)\java.lang.OutOfMemoryError: Java heap space *** java.lang.instrument ASSERTION FAILED ***: \byte arrau at ../../../src/share/instrument/JPLISAgent.c line: 775 at client.MyServiceStub.(MyServiceStub.java:103) at client.MyServiceStub.(MyServiceStub.java:89) at client.MyServiceStub.(MyServiceStub.java:140) at client.MyServiceClient2.main(MyServiceClient2.java:12) Exception in thread \TCP Connection(idle)\java.lang.OutOfMemoryError: Java heap 实验二:

1. 下载Axis2 1.5.6

http://mirror.bit.edu.cn/apache//axis/axis2/java/core/1.5.6/axis2-1.5.6-bin.zip 替换axis2工程中的目录

WEB-INF\\lib

WEB-INF\\modules axis2-web

下所有文件,重复实验一中的实验。

2. 使用jconsole观察,jvm内存使用平稳,未发现内存泄漏情况。

本文来源:https://www.bwwdw.com/article/u3u2.html

Top