• 使用jmeter模拟post请求在jforum论坛回帖报错


    一.问题描述
    1.使用jmeter模拟post请求在jforum论坛回帖报错,检查回帖发现并没有显示新的回帖信息,报错信息如下。
    -- BEGIN ERROR STACK TRACE
    net.jforum.exceptions.ForumException: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor205.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.jforum.Command.process(Command.java:114)
    at net.jforum.JForum.processCommand(JForum.java:217)
    at net.jforum.JForum.service(JForum.java:200)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
    at psiprobe.Tomcat90AgentValve.invoke(Tomcat90AgentValve.java:35)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.reflect.InvocationTargetException
    ... 33 more
    Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to net.jforum.util.legacy.commons.fileupload.FileItem
    at net.jforum.view.forum.common.AttachmentCommon.preProcess(AttachmentCommon.java:131)
    at net.jforum.view.forum.PostAction.insertSave(PostAction.java:1074)
    ... 33 more

    URL is: /jforum-2.1.9/jforum.page?null
    END ERROR STACK TRACE--

    二.问题分析
    1.检查报错信息,提示string字符串不能强制转换为fileupload.FileItem类型,查了一下fileupload.FileItem是java的一个fileupload类,用于文件上传功能,在回帖的网页看了一下,发现有个上传文件的按钮,随便上传了一个图片,用fiddler抓包如下。
    Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to net.jforum.util.legacy.commons.fileupload.FileItem

    三.解决方案
    1.通过对比2次抓包的数据,发现这个file_0不是字符串类型,而是octet-stream或者image/png或者其他application类型,所以需要在post请求里将参数file_0删除后提交,或者如果需要上传文件(比如图片),可以在jmeter的文件上传页签填写对应的信息。

    2.根据上面的2种方式修改后,再提交post请求,可以看到网页已经可以正常显示提交的回复消息了。

  • 相关阅读:
    Java 递归、尾递归、非递归、栈 处理 三角数问题
    vmware虚拟机迁移导致的eth0消失问题
    c语言输入输出
    改动虚拟机镜像的rootpassword
    面试题之变态跳台阶
    努力是种病:放慢节奏,才能快速奔跑(转)
    做技术到底可以做到哪种地步-技术为什么越走越窄 (转)
    wpf 客户端【JDAgent桌面助手】开发详解(三) 瀑布流效果实现与UI虚拟化优化大数据显示
    我为什么写博客(转)
    入行必读:互联网行业薪酬等级!看看你值多少钱?(转)
  • 原文地址:https://www.cnblogs.com/nonamelake/p/14460153.html
Copyright © 2020-2023  润新知