Forum Discussion

HP-Plano-TX-Soa's avatar
Occasional Contributor
11 years ago

Can't use com.eviware objects from inside groovy JAR file?

I have a central groovy script library in the form of a JAR file, which I place in the ....\bin\ext\ directory of the soapUI Free version. Within this JAR file I have a "customScripts" Package which I created, which contains a number of classes with their methods. In one of these classes I have a method, Teardown(). Within this method I attempt to use a soapUI com object, "com.eviware.soapui.SoapUI.logMonitor".

However, whenever I attempt to run a testCase which uses this central script library and tries to call the Teardown() method, I get the following error:

groovy.lang.MissingPropertyException: No such property: com for class: customScripts.teardownScripts
Possible solutions: log
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(
at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(
at customScripts.teardownScripts.Teardown(teardownScripts.groovy:86)
at customScripts.teardownScripts$ Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.runTearDownScript(
at java.util.concurrent.Executors$ Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)

Line 86 in my groovy script is exactly the line where I reference the com.eviware.soapui.SoapUI.logMonitor object.

This all works fine in soapUI Pro - the entire "customScripts" groovy library works perfectly, as I place it in the ....\bin\scripts\ directory.

But the Free version can't use a com.eviware. object from within a groovy script, and complains with the error above.

I get no errors when I compile the groovy scripts and create the JAR file.

Why can't I use a com.eviware object from within a groovy script in my custom JAR file???

Here is a sample call I make from within a testCase teardown script:

def tdscript = new customScripts.teardownScripts(log, context, testRunner, testCase)

Here is the source code for the class that contains the custom Teardown() method I am trying to run:

package customScripts;

import com.eviware.soapui.SoapUI.logMonitor.*;

class teardownScripts
def log
def context
def testRunner
def testCase

teardownScripts(log, context, testRunner, testCase)
this.log = log
this.context = context
this.testRunner = testRunner
this.testCase = testCase

def Teardown()
def testStep;
def tstype;
def tsname;
def myRequestStep;
def request;
def response;
def sts;


if (context.expand('${#TestCase#ScriptLogVerbose}') != "YES")

// Log the testCase name, status and all the testStep messages
def testCaseName = testCaseName

if ( testRunner.getStatus().toString() == 'FAILED' )
{ ("$testCaseName has failed")
{ ("$testCaseName has Passed")

for ( testStepResult in testRunner.getResults() )
testStep = testStepResult.getTestStep()
tstype = testStep.config.type
// tstype
tsname =
myRequestStep = testRunner.testCase.getTestStepByName("$tsname")

if ( tstype == "request" && myRequestStep.testRequest.messageExchange != null)
request = new String(myRequestStep.testRequest.messageExchange.rawRequestData)
response = new String(myRequestStep.testRequest.messageExchange.rawResponseData) ("\r\n\r\n" + "**** " + "$tsname: RAW REQUEST: " + request + "\r\n\r\n") ("\r\n\r\n" + "**** " + "$tsname: RAW RESPONSE: " + response + "\r\n\r\n")

sts = testStepResult.getStatus().toString() ("$tsname has status of: " + "$sts")
testStepResult.messages.each() { msg -> (tsname + ": " + msg) }

if (context.expand('${#TestCase#SaveLogFiles}') != "YES")

// Give SoapUI script logging a chance to catch up before attempting to capture the script log to a file

sleep (5000)

// Save the TestCase Log, error log and script log to a combined log file
// "soapUI log" can be replaced with http log, jetty log, script log, error log etc based on the need.

def logArea = null
def logMon = [b]com[/b].eviware.soapui.SoapUI.logMonitor
if ( logMon != null ) {
logArea = [b]com[/b].eviware.soapui.SoapUI.logMonitor.getLogArea( "script log" )

def path = context.expand('${#Project#Log_files_loc}')
def date = new Date()
def datefmt = new java.text.SimpleDateFormat('yyyy_MM_dd_kkmmss')
def timestamp = datefmt.format(date) timestamp

def logFile = new File(path + testCaseName + "_" + timestamp + ".txt") (path + testCaseName + "_" + timestamp + ".txt")
logFile.write("============================= SCRIPT LOGS: ===============================\r\n\r\n")
if( logArea != null )
def model = logArea.model
if( model.size > 0 ) {
for( c in 0..(model.size-1) ) {
logFile.append(model.getElementAt( c ).toString() + "\r\n")