本文介绍了JMeter代理和HTTP/POST中的Java序列化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个applet-servlet通信,我们想用JMeter的HTTP代理进行记录.它与GET消息一起使用,直到applet发送HTTP POST消息,其中包括一些序列化的Java对象(内置类型),然后我们在Applet中收到此错误:

We have an applet-servlet communication that we'd like to record with JMeter's HTTP proxy.It works with GET messages until the applet sends an HTTP POST message which includes some serialized Java objects (built-in types), then we get this error in the Applet:

替代文本http://img339.imageshack.us/img339/9238/appletservletjmeterhttp .png

好,因此队列中某处存在一些JVM版本冲突.但是在哪里?

OK, so there's some JVM version conflict somewhere in the queue. But where?

在没有JMeter的情况下,通信运行正常,即:Applet-> Tomcat-> Servlet.全部在我的本地计算机上.

The communication runs OK without JMeter, that is: Applet -> Tomcat -> Servlet. All on my local machine.

但是它不适用于JMeter:Applet-> JMeter代理-> Tomcat-> Servlet.也都在我的机器上.

But it doesn't work through JMeter: Applet -> JMeter proxy -> Tomcat -> Servlet. Also all on my machine.

就好像JMeter正在修改POST消息的内容...

It is as if JMeter was modifying the POST message content...

我也使用Apache代理对其进行了测试,效果很好.

I tested it with the Apache proxy as well, working fine.

更有趣的是,我只安装了一个Java版本,一个JDK和一个JRE.两者都是1.6.0_07 ...

Even funnier thing is that I have only one version of Java installed, one JDK and one JRE. Both 1.6.0_07...

在开始深入兔子洞之前,我会问;;)

Thought I'd ask before starting digging deeper in the rabbit hole ;-)

这是直接发送到Tomcat的POST数据的十六进制转储:

Here is the hex dump of the POST data sent directly to Tomcat:

00000348  ac ed 00 05 73 72 00 11  6a 61 76 61 2e 6c 61 6e ....sr.. java.lan
00000358  67 2e 49 6e 74 65 67 65  72 12 e2 a0 a4 f7 81 87 g.Intege r.......
00000368  38 02 00 01 49 00 05 76  61 6c 75 65 78 72 00 10 8...I..v aluexr..
00000378  6a 61 76 61 2e 6c 61 6e  67 2e 4e 75 6d 62 65 72 java.lan g.Number
00000388  86 ac 95 1d 0b 94 e0 8b  02 00 00 78 70 00 00 01 ........ ...xp...
00000398  7b                                               {

这是通过JMeter发送时的数据:

And here is the data when sent through JMeter:

00000128  ac ed 00 05 73 72 00 11  6a 61 76 61 2e 6c 61 6e ....sr.. java.lan
00000138  67 2e 49 6e 74 65 67 65  72 12 e2 a0 a4 f7 3f 3f g.Intege r.....??
00000148  38 02 00 01 49 00 05 76  61 6c 75 65 78 72 00 10 8...I..v aluexr..
00000158  6a 61 76 61 2e 6c 61 6e  67 2e 4e 75 6d 62 65 72 java.lan g.Number
00000168  3f ac 3f 1d 0b 3f e0 3f  02 00 00 78 70 00 00 01 ?.?..?.? ...xp...
00000178  7b                                               {

第二个转储中有很多"3f" ...因此,这绝对是某种编码问题.在标题中正确设置了内容类型:

A lot of "3f"s in the second dump...So this is definitely some kind of an encoding problem.The content type is set correctly in the header:

POST /ABCOrder/ABCServlet?cmd=getNetworkConnection HTTP/1.1
Connection: keep-alive
Content-Type: application/octet-stream
Host: 109.107.148.164:8443
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: Mozilla/4.0 (Windows Vista 6.0) Java/1.6.0_14
Content-Length: 81

推荐答案

以下是解决方案:JMeter有一个配置文件 bin/jmeter.properties .在这里,您可以找到一个可以设置二进制内容类型的选项:

Here is the solution: JMeter has a config file, bin/jmeter.properties.Here you can find an option where you can set the binary content types:

# Binary content-type handling
# These content-types will be handled by saving the request in a file:
proxy.binary.types=application/x-amf,application/x-java-serialized-object

现在我不知道为什么默认情况下不包括 application/octet-stream ,但是您只需将其添加到列表中就可以了.

Now I don't know why application/octet-stream isn't included by default, but you can simply add it to the list, and you are done.

proxy.binary.types=application/x-amf,application/x-java-serialized-object,application/octet-stream

这是我发现的方式: https://issues.apache.org/bugzilla/show_bug.cgi?id= 44808

This is how I found it out:https://issues.apache.org/bugzilla/show_bug.cgi?id=44808

已搜索JMeter的已关闭错误...:-)

Did a search on JMeter closed bugs... :-)

这篇关于JMeter代理和HTTP/POST中的Java序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 10:06