Jmeter书中不会教你的(28)——执行写入csv文件报错Typed variable declaration : Object constructor

本文介绍了在执行写入CSV文件脚本时遇到的错误,问题源于文件在执行过程中处于打开状态。解决方案是确保在执行前关闭文件,从而避免此类错误。对于编程和数据处理工作,了解如何正确管理和操作文件状态至关重要。

        今天分享一个小技巧,经常遇到在执行有写入csv脚本时,在log中出现以下错误信息

2021-11-25 10:05:56,257 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``//定义一个写入csv文件的地址 String filePath1 = "D://xntest//result.csv";  //定义一个写入的字段 Strin . . . '' : Typed variable declaration : Object constructor

        原因就是"D://xntest//result.csv"这个地址的文件状态是打开着的,关闭它再次执行就可以了。

-------------------------------------------------------------------------------

如果觉得我的文章对您有用,请收藏+关注,您的支持是我坚持的动力!

2025-07-01 15:17:22,311 INFO o.j.r.JARSourceHTTP: Found cached repo 2025-07-01 15:17:22,536 INFO o.j.r.PluginManager: Plugins Status: [jpgc-plugins-manager=1.11, jmeter-core=5.6.3, jmeter-ftp=5.6.3, jmeter-http=5.6.3, jmeter-jdbc=5.6.3, jmeter-jms=5.6.3, jmeter-junit=5.6.3, jmeter-java=5.6.3, jmeter-ldap=5.6.3, jmeter-mail=5.6.3, jmeter-mongodb=5.6.3, jmeter-native=5.6.3, jmeter-tcp=5.6.3, jmeter-components=5.6.3] 2025-07-01 15:17:32,191 INFO o.a.j.s.FileServer: Default base='D:\日常软件\H.Jmeter\apache-jmeter-5.6.3\bin' 2025-07-01 15:17:32,193 INFO o.a.j.g.a.Load: Loading file: D:\日常软件\H.Jmeter\查看结果树.jmx 2025-07-01 15:17:32,193 INFO o.a.j.s.FileServer: Set new base='D:\日常软件\H.Jmeter' 2025-07-01 15:17:32,240 INFO o.a.j.s.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2 2025-07-01 15:17:32,240 INFO o.a.j.s.SaveService: Using SaveService properties file encoding UTF-8 2025-07-01 15:17:32,240 INFO o.a.j.s.SaveService: Using SaveService properties version 5.0 2025-07-01 15:17:32,256 INFO o.a.j.s.SaveService: Loading file: D:\日常软件\H.Jmeter\查看结果树.jmx 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser 2025-07-01 15:17:32,557 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times 2025-07-01 15:17:32,557 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to UTF-8 2025-07-01 15:17:32,557 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true 2025-07-01 15:17:32,557 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000 2025-07-01 15:17:32,636 INFO o.a.j.r.ClassFinder: Will scan jar D:\日常软件\H.Jmeter\apache-jmeter-5.6.3\lib\ext\jmeter-plugins-manager-1.11.jar with filter ExtendsClassFilter [parents=[interface org.apache.jmeter.visualizers.ResultRenderer], inner=false, contains=null, notContains=null]. Consider exposing JMeter plugins via META-INF/services, and add JMeter-Skip-Class-Scanning=true manifest attribute so JMeter can skip classfile scanning 2025-07-01 15:17:32,636 INFO o.a.j.r.ClassFinder: Will scan jar D:\日常软件\H.Jmeter\apache-jmeter-5.6.3\lib\ext\jmeter-plugins-manager-1.11.jar with filter ExtendsClassFilter [parents=[interface org.apache.jmeter.visualizers.RequestView], inner=false, contains=null, notContains=null]. Consider exposing JMeter plugins via META-INF/services, and add JMeter-Skip-Class-Scanning=true manifest attribute so JMeter can skip classfile scanning 2025-07-01 15:17:32,668 INFO o.a.j.s.FileServer: Set new base='D:\日常软件\H.Jmeter' 2025-07-01 15:17:37,105 INFO o.a.j.e.StandardJMeterEngine: Running the test! 2025-07-01 15:17:37,105 INFO o.a.j.s.SampleEvent: List of sample_variables: [] 2025-07-01 15:17:37,105 INFO o.a.j.s.SampleEvent: List of sample_variables: [] 2025-07-01 15:17:37,105 INFO o.a.j.e.u.CompoundVariable: Note: Function class names must contain the string: '.functions.' 2025-07-01 15:17:37,105 INFO o.a.j.e.u.CompoundVariable: Note: Function class names must not contain the string: '.gui.' 2025-07-01 15:17:37,254 INFO o.a.j.r.ClassFinder: Will scan jar D:\日常软件\H.Jmeter\apache-jmeter-5.6.3\lib\ext\jmeter-plugins-manager-1.11.jar with filter ExtendsClassFilter [parents=[interface org.apache.jmeter.functions.Function], inner=false, contains=null, notContains=null]. Consider exposing JMeter plugins via META-INF/services, and add JMeter-Skip-Class-Scanning=true manifest attribute so JMeter can skip classfile scanning 2025-07-01 15:17:37,254 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*) 2025-07-01 15:17:37,254 INFO o.a.j.e.StandardJMeterEngine: Starting setUp thread groups 2025-07-01 15:17:37,254 INFO o.a.j.e.StandardJMeterEngine: Starting setUp ThreadGroup: 1 : tbd 线程组 2025-07-01 15:17:37,254 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group tbd 线程组. 2025-07-01 15:17:37,254 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error 2025-07-01 15:17:37,254 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false 2025-07-01 15:17:37,270 INFO o.a.j.t.ThreadGroup: Started thread group number 1 2025-07-01 15:17:37,270 INFO o.a.j.e.StandardJMeterEngine: Waiting for all setup thread groups to exit 2025-07-01 15:17:37,270 INFO o.a.j.t.JMeterThread: Thread started: tbd 线程组 1-1 2025-07-01 15:17:37,270 INFO o.a.j.p.h.s.HTTPHCAbstractImpl: Local host = jizhi 2025-07-01 15:17:37,285 INFO o.a.j.p.h.s.HTTPHC4Impl: HTTP request retry count = 0 2025-07-01 15:17:37,424 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``// JSR223 Sampler 中使用 import org.apache.http.client.methods.HttpPost; import org . . . '' : Typed variable declaration : Object constructor 2025-07-01 15:17:37,424 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``// JSR223 Sampler 中使用 import org.apache.http.client.methods.HttpPost; import org . . . '' : Typed variable declaration : Object constructor 2025-07-01 15:17:37,460 INFO o.a.j.t.JMeterThread: Thread is done: tbd 线程组 1-1 2025-07-01 15:17:37,460 INFO o.a.j.t.JMeterThread: Thread finished: tbd 线程组 1-1 2025-07-01 15:17:37,475 INFO o.a.j.e.StandardJMeterEngine: All Setup Threads have ended 2025-07-01 15:17:37,539 INFO o.a.j.e.StandardJMeterEngine: No enabled thread groups found 2025-07-01 15:17:37,539 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test 2025-07-01 15:17:37,539 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
07-02
2025-07-01 15:20:56,557 INFO o.a.j.e.StandardJMeterEngine: Running the test! 2025-07-01 15:20:56,557 INFO o.a.j.s.SampleEvent: List of sample_variables: [] 2025-07-01 15:20:56,557 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*) 2025-07-01 15:20:56,557 INFO o.a.j.e.StandardJMeterEngine: Starting setUp thread groups 2025-07-01 15:20:56,557 INFO o.a.j.e.StandardJMeterEngine: Starting setUp ThreadGroup: 1 : tbd 线程组 2025-07-01 15:20:56,557 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group tbd 线程组. 2025-07-01 15:20:56,557 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error 2025-07-01 15:20:56,557 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false 2025-07-01 15:20:56,557 INFO o.a.j.t.ThreadGroup: Started thread group number 1 2025-07-01 15:20:56,557 INFO o.a.j.e.StandardJMeterEngine: Waiting for all setup thread groups to exit 2025-07-01 15:20:56,557 INFO o.a.j.t.JMeterThread: Thread started: tbd 线程组 1-1 2025-07-01 15:20:56,677 INFO o.a.j.u.BeanShellTestElement: Classpath: /D:/%e6%97%a5%e5%b8%b8%e8%bd%af%e4%bb%b6/H.Jmeter/apache-jmeter-5.6.3/bin/ApacheJMeter.jar 2025-07-01 15:20:56,677 INFO o.a.j.u.BeanShellTestElement: ✅ ITesseract 类加载成功 2025-07-01 15:20:56,783 INFO o.a.j.t.JMeterThread: Thread is done: tbd 线程组 1-1 2025-07-01 15:20:56,783 INFO o.a.j.t.JMeterThread: Thread finished: tbd 线程组 1-1 2025-07-01 15:20:56,783 INFO o.a.j.e.StandardJMeterEngine: All Setup Threads have ended 2025-07-01 15:20:56,924 INFO o.a.j.e.StandardJMeterEngine: No enabled thread groups found 2025-07-01 15:20:56,924 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test 2025-07-01 15:20:56,924 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
07-02
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

agrapea

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值