Ask a Question

Known limitations of custom groovy classes packaged in a JAR file

Occasional Contributor

Known limitations of custom groovy classes packaged in a JAR file



I created a custom Groovy library to store some reusable functions and used them in the SoapUI tests. I observed a couple of limitations with this approach


- When an exception occurs in a function of the library, system does not show any details in output but will show the error log specific to groovy steps in the SoapUI test case

- Console output cannot be printed to SoapUI "Script Log". e.g. using "println" in the groovy class


If you tried developing a library for using it in SoapUI, could you please provide your inputs and list any limitations you found.


Thank you




Community Hero

Can you share the respective code of the above issue?

Valued Contributor



Thanks for the questions here and on the blog:


On the first question about the exception handing behaviour, an example would help as @nmrao said.


The second question about how to log from the extension is a good one, ideally I'd like to add that to the blog, but will try to reply here first for time reasons. So, perhaps the easiest way is to just get hold of SoapUI's script log tab using Log4J. Following on from the blog, please consider the following simple extension library class:

package custom 
import org.apache.log4j.Logger 

public class SequentialIdGenerator { 
   public static final Logger soapuiLogFileLogger = Logger.getLogger(getClass())
   public static final Logger scriptLogger = Logger.getLogger("groovy.log")

   public static void logSomething(){ "Hello scriptlog from extension!"


To compile this with Gradle, we need to add the Log4J dependency: 

apply plugin: 'groovy'

version = '1.0'

jar {
    classifier = 'sample'
    manifest {
    	attributes 'Implementation-Title': 'SoapUI Sample Groovy Library', 'Implementation-Version': version

repositories {

dependencies {
   compile 'org.codehaus.groovy:groovy:2.1.7'
   compile group: 'log4j', name: 'log4j', version: '1.2.17'

Once, build i.e. gradle clean build jar, the jar added to SoapUI /ext folder and SoapUI restarted, we can call the class and see logging in the standard SoapUI 'script log' tab:

Screen Shot 2017-06-30 at 09.22.16.png

Is this what you wanted?


As for other imitations, we would need to discuss them in turn. I am not sure that there are specific limitations as such, more things we need to provide extra code for, but it does depend on exactly what you need to do. For example, this approach is probably not a good way to extend/override the core SoapUI functionality e.g. better to do it directly in the product source or possibly via a plugin. 






Author of SoapUI Cookbook
Occasional Contributor

Thanks Rupert. The logging solution provided is what I am after


Regarding the question 1, 

- I added a file in my Groovy project with a specific path.

- The Jar artifact is built and placed in "ext" folder of SoapUI

- Ran the testcase using the function in Jar

- The function code haven't found the file (unable to get that path) 

- This error/exception is not propagated to UI but a default value is returned based on the functions return type e.g. null 


With the log functionality working now, I can add some exception handling in Groovy library which will print any errors to the SoapUI log.




Showing results for 
Search instead for 
Did you mean: