开发者社区 问答 正文

jmeter beanshell 对象序列化报错 ?报错

1.在jmeter中编写beanshell代码,创建消息对象,再对对象序列化,运行报错:
Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import com . . . '' : Typed variable declaration : Method Invocation msg.serialize
2.//序列化
byte[] buff = msg.serialize();
3.beanshell截图
图片说明

展开
收起
爱吃鱼的程序员 2020-06-23 01:16:36 598 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    加入trycatch,发现有个类找不到,导入jar包后正常
    1.try{
    buff=msg.serialize();
    log.info("buff:"+buff);
    sBuff=buff.toString();
    log.info("sBuff:"+sBuff);
    vars.put("preMsg",sBuff);
    log.info("preMsg:"+preMsg);
    }catch(Throwableex){
    log.error("Beanshellfailure:",ex);;
    }
    2.importio.netty.util.internal.StringUtil;

    让你的实体类implementsSerializable

    2020-06-23 01:16:53
    赞同 展开评论