Tomcat 和 JMeter 生成 HTTP 404 错误
我对 JMeter 完全是新手。我正在尝试使用 JMeter 连接到 Tomcat 中部署的 Web 应用程序,以模拟少量用户登录并浏览页面。
当我运行测试计划时,JMeter 日志显示一系列 HTTP 404 消息,表明某处存在通信问题。
以下链接显示了测试计划的 HTTP 默认值:
alt text http:// /www.dcs.bbk.ac.uk/~martin/uploads/HTTP_Defaults.PNG
接下来有两个简单的 HTTP 请求。
第一个请求应使用户能够登录:
alt text http: //www.dcs.bbk.ac.uk/~martin/uploads/Login.PNG
第二个请求应允许新登录的用户浏览页面:
替代文本 http://www.dcs.bbk.ac.uk/~martin/uploads/Browse.PNG< /a>
但是,正如我所说,我在 JMeter 日志中收到的只是 HTTP 404 消息:
2009/09/23 15:10:43 INFO - jmeter.protocol.http.sampler.HTTPSampler: Error Response Code: 404
Tomcat 在测试期间正在运行,并且在测试计划中,我还将 HTTP Cookie 管理器设置为“默认”。
当我的应用程序在 Tomcat 下测试时运行时,其 URL 为 http://localhost:8080/myDataSharer,我试图让 JMeter 反映这一点。
任何帮助都会受到欢迎,因为我不明白为什么 JMeter 和 Tomcat 不互相交谈。
谢谢马丁
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
HTTP 请求默认值 中的路径 未添加到HTTP 请求 中路径 的开头。将上下文根 myDataSharer 添加到 HTTP 请求 中的路径。
如果您不想到处重复,可以使用一个配置元素,您可以在其中定义属性,然后像这样 ${my.propertie} 一样引用它。
另外,您应该添加一个显示请求和响应数据的元素,我认为它称为结果树或类似的东西。
编辑 1: 另一件看起来很奇怪的事情是登录请求的路径。该网址正确吗?不应该是
j_acegi_security_check
吗?这是出现在登录表单操作中的 url 吗?编辑2:在Tomcat中有一个用于测试安全性的示例应用程序:
http://example.com:8080/examples/jsp/security/ protected/login.jsp
用户位于 conf/tomcat-users.xml 中。添加一个角色:role1,如下所示:
启动服务器,您应该能够登录。然后尝试这个JMeter测试计划:
看看我在登录获取cookie之前添加了一个额外的请求。如果不这样做,登录将失败并显示 408 代码。
如果您让它正常工作,那么您的应用程序就可以以相同的方式进行测试。
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:
Start the server and you should be able to login. Then try this JMeter test plan:
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.
最后,我让这个东西工作了 - 这是一个将自动重定向更改为遵循请求中的重定向的情况。感谢罗德里戈普的帮助
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