Search code examples
windowsgroovyjmetergroovy-grape

JMeter Grape config for groovy on Windows?


Currently I'm trying to run groovy scripts in JMeter with grape in windows: My JMeter has c:\JMeter\lib\groovy-all.2.4.16.jar, c:\JMeter\lib\ivy-2.5.0.jar (heard needed this).

A lot of examples I see for grape config are in Linux. I put the grapeConfig.xml in c:\JMeter\ with the following settings:

<ivysettings>
  <settings defaultResolver="downloadGrapes"/>
  <resolvers>
    <chain name="downloadGrapes">
      <filesystem name="cachedGrapes">
        <ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
        <artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
      </filesystem>
      <!-- todo add 'endorsed groovy extensions' resolver here -->
      <ibiblio name="codehaus" root="http://repository.codehaus.org/" m2compatible="true"/>
      <ibiblio name="ibiblio" m2compatible="true"/>
      <ibiblio name="java.net2" root="http://download.java.net/maven/2/" m2compatible="true"/>
      <!-- this fixes the missing 2.1_3 version of cglib-nodep -->
      <ibiblio name="mirror" root="http://mirrors.ibiblio.org/maven2/" m2compatible="true"/>
    </chain>
  </resolvers>
</ivysettings>

When I execute a script in JMeter I get the following error as part of a groovy @Grab:

General error during conversion: Error grabbing Grapes -- [download failed: commons-logging#commons-logging;1.1.1!commons-logging.jar]

java.lang.RuntimeException: Error grabbing Grapes -- [download failed: commons-logging#commons-logging;1.1.1!commons-logging.jar]

Any help would be greatly appreciated on getting proper configuration of grape with JMeter and groovy on Windows?


Solution

  • As per Global grapeConfig.xml thread Grape is checking the following:

    • grape.config system property (if it is not null)
    • groovy.root system property (if it is not null)
    • user.home/.groovy folder

    So in order to "tell" JMeter to use your custom grapeConfig.xml you need to launch JMeter like:

    jmeter -Dgrape.config=c:/JMeter/grapeConfig.xml -t your_script.jmx
    

    To make the change permanent add the next line to system.properties file:

    grape.config=c:/JMeter/grapeConfig.xml
    

    More information: