Script6.groovy: : 意外输入:Jmeter JSR233 预处理器错误

Script6.groovy: : Unexpected input: Jmeter JSR233 preprocessor error

我正在尝试导入一个 jar(在 testplan 中导入 jar)并使用这些方法帮助在我的 XML 消息中生成数字签名。但是我看到 groovy 错误:

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script6.groovy: 7: Unexpected input: '(' @ line 7, column 59.
   alSignatureFactory.getInstance("C\:\Proj
                                 ^

代码很简单,如下。为什么在 '('

import com.aciworldwide.generic.stress.simulator.crypto.xml.signing.DigitalSignature;
import com.aciworldwide.generic.stress.simulator.crypto.xml.signing.DigitalSignatureFactory;
import java.util.*
import groovy.xml.*


DigitalSignature sig = DigitalSignatureFactory.getInstance("C:\Projects\NFRPERF\trunk\BI-Fast_CI_HUB\jmeterscripts\crypto\server.keys.p12", "server.key.pair", "aciworldwide", "PKCS12");

您需要用另一个反斜杠转义这些反斜杠,即

"C:\Projects\NFRPERF\trunk\BI-Fast_CI_HUB\jmeterscripts\crypto\server.keys.p12"

或改用正斜杠:

"C:/Projects/NFRPERF/trunk/BI-Fast_CI_HUB/jmeterscripts/crypto/server.keys.p12"

或使用Groovy的Slashy String:

/C:\Projects\NFRPERF\trunk\BI-Fast_CI_HUB\jmeterscripts\crypto\server.keys.p12/

更多信息: