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

偶尔善良 提交于 2019-12-01 02:30:59

问题


I am trying to create a JMeter load test. 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:

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.

Does anyone know why I am getting this error? Does the beanshell preprocessor not work in the way I am trying to use it?


回答1:


My guess is that the problem is that it's not populating the varargs parameter. Try:

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


来源:https://stackoverflow.com/questions/32202068/jmeter-static-method-get-java-lang-string-not-found-in-classjava-nio-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!