简体   繁体   English

JMeter - 在类'java.nio.file.Paths'中找不到静态方法get(java.lang.String)

[英]JMeter - Static method get( java.lang.String ) not found in class'java.nio.file.Paths'

I am trying to create a JMeter load test. 我正在尝试创建JMeter负载测试。 I need the test to take a sample log file and change its name. 我需要测试来获取示例日志文件并更改其名称。 The only way I could find to do this was to copy the file in a BeanShell Preprocessor but I am getting the following error: 我能找到的唯一方法是在BeanShell预处理器中复制文件,但是我收到以下错误:

ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: evalSourced file: inline evaluation of: ``import java.nio.file.StandardCopyOption; import java.io.IOException; import java . . . '' : Typed variable declaration : Error in method invocation: Static method get( java.lang.String ) not found in class'java.nio.file.Paths'

The code I am using is the following: 我使用的代码如下:

import java.nio.file.StandardCopyOption;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

Path source = Paths.get(vars.get("filename");

String filename = "/Users/GX1/Desktop/jmeter/tmp/Device_"+vars.get("global_counter")+"_upload_"+vars.get("file_counter")+".csv.gz";

Path target = Paths.get(filename);
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
vars.put("filename", filename);

filename, global_counter and file_counter are jmeter variables. filename,global_counter和file_counter是jmeter变量。

Does anyone know why I am getting this error? 有谁知道我为什么会收到这个错误? Does the beanshell preprocessor not work in the way I am trying to use it? beanshell预处理器不能像我尝试使用它那样工作吗?

My guess is that the problem is that it's not populating the varargs parameter. 我的猜测是问题是它没有填充varargs参数。 Try: 尝试:

Path target = Paths.get(filename, new String[0]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 复制文件时,JMeter Bean Shell采样器错误“在类'java.nio.file.Paths中找不到静态方法get(java.lang.String)” - JMeter Bean Shell Sampler error “…Static method get( java.lang.String ) not found in class'java.nio.file.Paths” when copying files 如何在 nashorn javascript 中使用 Paths(java.nio.file.Paths) - How to use Paths(java.nio.file.Paths) in nashorn javascript Java.nio.file.Paths为当前目录提供了错误的路径? - Java.nio.file.Paths is giving incorrect path for current directory? Java6中java.nio.file.Paths的替代方法 - Alternative to java.nio.file.Paths in Java6 在类中找不到JMETER Beanshell(java.lang.String) - JMETER Beanshell ( java.lang.String ) not found in class 在 java.util.Arrays 类中找不到静态方法 asList( java.lang.String ) - Static method asList( java.lang.String ) not found in the java.util.Arrays class 找不到JSP方法:类java.lang.String - JSP Method not found: class java.lang.String java.nio.file.Paths - 如何在迭代时跳过无法访问的文件/文件夹 - java.nio.file.Paths - How to skip unaccessible file/folder while iterating 使用java.nio.file.Paths接口时缺少方案(IllegalArgumentException) - Missing scheme (IllegalArgumentException) while using java.nio.file.Paths interface 使用 java.nio.file.Paths & jsfml loadFromFile 时发生死锁 - Deadlock occurring when using java.nio.file.Paths & jsfml loadFromFile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM