JMeter proxy and Java serialization to HTTP / POST?
We have a connection to a servlet applet that we would like to record using a JMeter HTTP proxy. It works with GET messages until the applet sends an HTTP POST message that includes some serialized Java objects (built-in types), then we get this error in the applet:
alt text http://img339.imageshack.us/img339/9238/appletservletjmeterhttp.png
OK, so some JVM versions conflict somewhere in the queue. But where?
Communication works fine without JMeter, that is: Applet -> Tomcat -> Servlet. Everything on my local machine.
But this doesn't work via JMeter: Applet -> JMeter proxy -> Tomcat -> Servlet. Also everything is on my machine.
It's as if JMeter was modifying the content of the POST message ...
I also tested it with Apache proxy, working great.
Even funnier is that I only have one Java version, one JDK and one JRE. And 1.6.0_07 ...
Thought I'd ask before I start digging deeper into the rabbit hole ;-)
Here is a 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 {
And here is the data sent via 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 {
Lots of "3f" in the second dump ... So this is definitely some kind of 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
source to share
Here's the solution: JMeter has a config file, bin / jmeter.properties . You can find an option here where you can set 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
Now I don't know why application / octet-stream is not enabled by default, but you can just add it to the list and you're done.
proxy.binary.types=application/x-amf,application/x-java-serialized-object,application/octet-stream
This is how I figured it out: https://issues.apache.org/bugzilla/show_bug.cgi?id=44808
Was searching on JMeter for closed errors ... :-)
source to share
Someone else reports very similarly: http://markmail.org/message/pl5erin2isehm5q6 . However, I cannot find the issue related to this issue in the bug tracker . Looks like you've won the privilege of going deeper into the rabbit hole :)
source to share
The accepted response only allows writing static requests. This will not be realistic as it will not allow you to change the query validation (like changing the search word ...), so you will always be stressed with the same bunch of data.
To make this a real test, you need to use a third party plugin.
The commercial JMeter plugin allows you to:
To make your tests realistic, you will need to modify the content in the serialized objects.
This Java Serialization plugin will allow the following:
-
Light traffic recording will be generated using JMeter proxy, test plan will be generated using custom Sampler
-
Easy variation of queries (to be displayed as XML) through simple syntax like $ {searchWord}, ββwhere searchWord can come from CSV or any custom variable.
-
Easily extract data from responses using standard JMeter post processors
-
Easy debugging of requests / responses through the standard JMeter view result tree item
Disclaimer: I work for this company.
source to share