Question

I'm a complete novice with JMeter. I'm trying to use JMeter to connect to a web application deployed in Tomcat to simulate a small number of users logging in and browsing a page.

When I ran the test plan, JMeter log showed a series of HTTP 404 messages indicating that there was a communications problem somewhere.

The following link shows the test plan's HTTP defaults:

alt text http://www.dcs.bbk.ac.uk/~martin/uploads/HTTP_Defaults.PNG

With two simple HTTP requests to follow.

The first request should enable the users to log in:

alt text http://www.dcs.bbk.ac.uk/~martin/uploads/Login.PNG

And the second request should allow the newly logged in users to browse a page:

alt text http://www.dcs.bbk.ac.uk/~martin/uploads/Browse.PNG

But, as I said, all I received in the JMeter logs were HTTP 404 messages:

2009/09/23 15:10:43 INFO  - jmeter.protocol.http.sampler.HTTPSampler: Error Response Code: 404 

Tomcat is running during the test and in the test plan, I also have a HTTP Cookie Manager set to 'default'.

When my application runs under Tomcat in test, its URL is http://localhost:8080/myDataSharer and I'm trying to have JMeter reflect this.

Any help would be welcome as I can't work out why JMeter and Tomcat aren't talking to each other.

Thanks

Martin

Was it helpful?

Solution

The path in HTTP Request Defaults is not added at the beginning of the path in HTTP Request. Add the context root myDataSharer to the path in HTTP Request.
If you don't want to repeat it everywere, there is a Configuration Element where you can define proeprties and later reference it like this ${my.propertie}.
Also you should add an element that shows request and response data, I think it's called Result Tree or something like that.

Edit 1: Another thing that looks extrange is the path of the Login request. Is that URL correct? Shouldn't it be j_acegi_security_check? Is that the url that appears in the action of the login form?

Edit 2: In Tomcat there is an example application used to test security:
http://example.com:8080/examples/jsp/security/protected/login.jsp

The users are in conf/tomcat-users.xml. Add one with the role: role1 like this:

<role rolename="role1"/>
<user username="test" password="test" roles="role1"/>

Start the server and you should be able to login. Then try this JMeter test plan:

<jmeterTestPlan version="1.2" properties="1.8">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Plan de Pruebas" enabled="true">
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <stringProp name="TestPlan.comments"></stringProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Grupo de Hilos" enabled="true">
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
        <longProp name="ThreadGroup.start_time">1157555458000</longProp>
        <stringProp name="ThreadGroup.on_sample_error">stoptest</stringProp>
        <stringProp name="ThreadGroup.ramp_time">0</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <stringProp name="LoopController.loops">1</stringProp>
          <boolProp name="LoopController.continue_forever">false</boolProp>
        </elementProp>
        <longProp name="ThreadGroup.end_time">1157555458000</longProp>
      </ThreadGroup>
      <hashTree>
        <CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="Gestor de Cookies HTTP" enabled="true">
          <boolProp name="CookieManager.clearEachIteration">false</boolProp>
          <collectionProp name="CookieManager.cookies"/>
        </CookieManager>
        <hashTree/>
        <HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" testname="Petición HTTP" enabled="true">
          <stringProp name="HTTPSampler.domain">localhost</stringProp>
          <stringProp name="HTTPSampler.FILE_NAME"></stringProp>
          <stringProp name="HTTPSampler.path">/examples/jsp/security/protected/login.jsp</stringProp>
          <stringProp name="HTTPSampler.method">GET</stringProp>
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
          <stringProp name="HTTPSampler.mimetype"></stringProp>
          <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
          <stringProp name="HTTPSampler.port">8080</stringProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <stringProp name="HTTPSampler.monitor">false</stringProp>
          <stringProp name="HTTPSampler.protocol"></stringProp>
        </HTTPSampler>
        <hashTree/>
        <HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" testname="Petición HTTP" enabled="true">
          <stringProp name="HTTPSampler.domain">localhost</stringProp>
          <stringProp name="HTTPSampler.FILE_NAME"></stringProp>
          <stringProp name="HTTPSampler.path">/examples/jsp/security/protected/j_security_check</stringProp>
          <stringProp name="HTTPSampler.method">POST</stringProp>
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="" elementType="HTTPArgument">
                <boolProp name="HTTPArgument.use_equals">true</boolProp>
                <boolProp name="HTTPArgument.always_encode">false</boolProp>
                <stringProp name="Argument.name">j_username</stringProp>
                <stringProp name="Argument.value">test</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
              <elementProp name="" elementType="HTTPArgument">
                <boolProp name="HTTPArgument.use_equals">true</boolProp>
                <boolProp name="HTTPArgument.always_encode">false</boolProp>
                <stringProp name="Argument.name">j_password</stringProp>
                <stringProp name="Argument.value">test</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
          <stringProp name="HTTPSampler.mimetype"></stringProp>
          <boolProp name="HTTPSampler.auto_redirects">true</boolProp>
          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
          <stringProp name="HTTPSampler.port">8080</stringProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <stringProp name="HTTPSampler.monitor">false</stringProp>
          <stringProp name="HTTPSampler.protocol">http</stringProp>
        </HTTPSampler>
        <hashTree/>
        <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="Ver Árbol de Resultados" enabled="true">
          <objProp>
            <value class="SampleSaveConfiguration">
              <time>true</time>
              <latency>true</latency>
              <timestamp>true</timestamp>
              <success>true</success>
              <label>true</label>
              <code>true</code>
              <message>true</message>
              <threadName>true</threadName>
              <dataType>true</dataType>
              <encoding>false</encoding>
              <assertions>true</assertions>
              <subresults>true</subresults>
              <responseData>false</responseData>
              <samplerData>false</samplerData>
              <xml>false</xml>
              <fieldNames>false</fieldNames>
              <responseHeaders>false</responseHeaders>
              <requestHeaders>false</requestHeaders>
              <responseDataOnError>false</responseDataOnError>
              <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
              <assertionsResultsToSave>0</assertionsResultsToSave>
            </value>
            <name>saveConfig</name>
          </objProp>
          <stringProp name="filename"></stringProp>
          <boolProp name="ResultCollector.error_logging">false</boolProp>
        </ResultCollector>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

Look that I added an extra request before loging in to get the cookie. If you don't do that login will fail with a 408 code.

If you get this to work then your application can be tested in the same way.

OTHER TIPS

Finally, I have this thing working - it was a case of changing Redirect Automatically to Follow Redirects in the requests. Thanks to Rodrigoap for his assistance

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top