jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Caccia <>
Subject Groovy GString incompatibility?
Date Mon, 23 Dec 2013 02:58:58 GMT

I have a JMeter test (2.10) that uses a JSR223 script sampler.  The groovy script was working
fine.  I then learned about GStrings and decided to convert the script to use that.  After
making the change, the groovy script fails to compile in JMeter (compiles fine in groovy console).

Here's an example, this will fail in JMeter:


import groovy.sql.Sql

def projectName = vars.get("projectName")
def sql = Sql.newInstance("jdbc:sqlserver://SERVERNAME\\DBINSTANCE:PORT", "reporter", "reporter",

//def row = sql.firstRow("select projectId from projects where projectName = '" + projectName
+ "'")
def row = sql.firstRow("select projectId from projects where projectName = '${projectName}'")

The JMeter log will report an unexpected character on the line for "def sql =" at character

If I uncomment the 2nd to last line and comment out the last line, then the script runs fine
in JMeter.  Am I missing something or is this a defect in JMeter?

The error dump looks like:

2013/12/22 18:40:41 ERROR - Problem in JSR223
script javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed:
Script9.groovy: 5: unexpected char: '\' @ line 5, column 60.

    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(
    at javax.script.AbstractScriptEngine.eval(
    at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(
    at org.apache.jmeter.threads.JMeterThread.process_sampler(
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message