Forum Discussion

KMR's avatar
KMR
Occasional Contributor
12 years ago

Error in loading groovy class with maven plug in

Can you please let me know how I can load the groovy libraries through the pom file so that my scripts can work fine.
i am using soapUi version 4.6.1 and soapUi-maven-plugin 4.6.1

Below is the details of the issue I am facing
I have created a groovy class file which is placed in the the <soapui installation folder>/bin/script
My soapUi test cases are referring to the functions inside the class library. Scripts are working fine and I am able to execute them from test runner also.

Now I am trying to integrate the soapUi scripts with maven.
When I execute the scripts through maven, I am getting the below error.

Error:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unable to resolve class scripts.testLibrary
@ line 1, column 17.
def testClass = new scripts.testLibrary()
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class scripts.testLibrary
@ line 1, column 17.
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:148)
at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:229)
at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:239)

3 Replies

  • SiKing's avatar
    SiKing
    Community Expert
    You have one of two options. The easier is to use either the SoapUI script library. The much, much, much more difficult way is to generate a class file, upload it to a local artifactory, and set it as a dependency in your pom file.
  • KMR's avatar
    KMR
    Occasional Contributor
    Thanks for the response.
    With the soapUi-maven-plugin , for free version the Script Library files were not getting added.

    Another work around I was able to do is to use the soapUi-pro-maven-plugin , added the script library path in the tag
    <con:setting id="Script Library"></con:setting>

    Let me explore more to see if there is an option to load it using soapUi-maven-plugin with out using jar
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    Hi, you can also use additional plugin configuration (only for the pro plugin, as external groovy scripts is a pro feature)

    <soapuiProperties>
    <property>
    <name>soapui.scripting.library</name>
    <value>path_to_your_groovy_scripts</value>
    </property>
    </soapuiProperties>


    That way, you don't rely on the settings file and you do not have to generate a jar

    With the open source version, you will have to generate the jar and add dependencies configuration when declaring the soapui plugin.