Bug 50963 - AjpSampler throws java.lang.StringIndexOutOfBoundsException
Summary: AjpSampler throws java.lang.StringIndexOutOfBoundsException
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 2.4
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Keywords: ErrorMessage
Depends on:
Reported: 2011-03-23 19:33 UTC by Rebeccah
Modified: 2011-03-24 13:01 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Rebeccah 2011-03-23 19:33:37 UTC
I've googled and can find very little about JMeter and AJP other than the existance of an AJP1.3 sampler; certainly nothing resembling what I am seeing.

I have tomcat running behind IIS over AJP 1.3, with IIS/Windows handling user authentication using the Windows domain authentication.  Rather than load test our domain controller's authentication function, I thought I would test tomcat itself over the AJP connector.  I have the Tomcat AJP connector set to port 8009 with SSL redirect to port 443; any other connector settings are at default.  All of the pages of the web application under test have a security-constraint requiring SSL encryption.  JMeter testing using the tomcat HTTP and HTTPS ports (which will eventually be firewalled off) works fine.  I have used a standalone commandline AJPClient to confirm that I can communicate over our intranet with tomcat using AJP and get a 200 status code.

I create a new JMeter test plan from scratch:
  - one Thread Group, containing
  - one AJPSampler 
      - https protocol
      - port 8009
      - 60000ms timeouts
      - my desired hostname and web page 
      - follow redirects (or redirect automatically, same results either way)
      - use keep-alive 
   - one Response Assertion that checks for a 200 status code
   - a View Results Tree Listener
I save and then run the test plan
From the UI standpoint, nothing happens.  The sampler never shows up in the view.

Next, I take an existing test plan and edit the element tag for the sampler to reflect an AjpSampler instead of an HTTPSampler:
  - change
    <HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" testname="Grp1 Calculator web form HTTP Request" enabled="true">...</HTTPSampler>
    <AjpSampler guiclass="AjpSamplerGui" testclass="AjpSampler" testname="Grp1 Calculator web form AJP/1.3" enabled="true">...</AjpSampler>
I save and then run the test plan
In the UI, this sampler fails with a null response.

In both cases, when I look at the JMeter log file, I see:

2011/03/23 15:16:23 ERROR - jmeter.threads.JMeterThread: Error while processing sampler 'AJP/1.3 Sampler - MSScalculator app' : java.lang.StringIndexOutOfBoundsException: String index out of range: 41099
	at java.lang.String.checkBounds(Unknown Source)
	at java.lang.String.<init>(Unknown Source)
	at org.apache.jmeter.protocol.http.sampler.AjpSampler.getString(AjpSampler.java:499)
	at org.apache.jmeter.protocol.http.sampler.AjpSampler.parseHeaders(AjpSampler.java:443)
	at org.apache.jmeter.protocol.http.sampler.AjpSampler.handshake(AjpSampler.java:392)
	at org.apache.jmeter.protocol.http.sampler.AjpSampler.execute(AjpSampler.java:381)
	at org.apache.jmeter.protocol.http.sampler.AjpSampler.sample(AjpSampler.java:112)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:965)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:951)
	at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:348)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:243)
	at java.lang.Thread.run(Unknown Source)

If I create another AJP sampler in the UI change the protocol from https to http and change the target path to the tomcat manager app, I get the same UI behavior and the same exception with a different out-of-range index value (41086).
Comment 1 Rebeccah 2011-03-23 20:36:09 UTC
I just realized, the exception I am reporting in AjpSampler is identical to the one reported in Bug 47242 Comment 6, in the AJP commandline client code that Ken Van Camp was asking for (and that I downloaded from that thread to confirm I had AJP access across my Intranet).

In that thread, chamith buddhika did post a patch for the commandline AJP client last April.  Perhaps it can be incorporated into JMeter?


Comment 2 Sebb 2011-03-23 21:01:10 UTC
I've found one bug, which is that the code fails to skip past the control integer used for header translation, so the value is then used as the length for the next String.

Not sure if that is the same bug as in Bug 47242 - there's rather a lot of code to scan to see if it is.

URL: http://svn.apache.org/viewvc?rev=1084822&view=rev
Bug 50963 - AjpSampler throws java.lang.StringIndexOutOfBoundsException


The code is in nightly builds from r1084822.
Comment 3 Rebeccah 2011-03-24 13:01:24 UTC
Thank you very much for jumping on this so quickly.