Forum Discussion

jacky's avatar
15 years ago

Error running groovy script in soapui

Hello everybody,
I'm running this piece of code on soaup :

import com.thoughtworks.selenium.*

class prova1groovy extends GroovySeleneseTestCase {

@Override
void setUp() throws Exception {
super.setUp('http://en.wikipedia.org/', '*chrome')
setDefaultTimeout(30000)
setCaptureScreenshotOnFailure(false)
}

void testWikipedia() throws Exception {
selenium.open("/wiki/Main_Page")
selenium.type("searchInput", "webservice")
selenium.click("searchGoButton")
}
}

but i've always gotten this error:

ERROR:groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class prova1groovy. Reason: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@11ba6f' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'
groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class prova1groovy. Reason: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@11ba6f' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'
at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:430)
at groovy.lang.GroovyShell.parse(GroovyShell.java:739)
at groovy.lang.GroovyShell.parse(GroovyShell.java:766)
at groovy.lang.GroovyShell.parse(GroovyShell.java:757)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:148)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException:
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:327)
at org.codehaus.groovy.reflection.CachedField.setProperty(CachedField.java:65)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2359)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3315)
at org.codehaus.groovy.runtime.InvokerHelper.setProperties(InvokerHelper.java:450)
at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:427)

Please somebody can help me
  • sirba01's avatar
    sirba01
    Occasional Contributor
    Hi Jacky,

    did you manage to get the solution for this? i am having the same problem as well.

    Thanks,
    Balaji
  • Hi!

    Judging from the error, you are somewhere in your code casting the default log object (of type org.apache.log4j.Logger) to the corresponding Logger in the java.util.logging.Logger class.. could that be? Try searching your imports for the wrong class...

    regards,

    /Ole
    eviware.com
  • sirba01's avatar
    sirba01
    Occasional Contributor
    Thanks for your reply,

    i was just trying to run Groovy script recorded from selenium, i did not write any specific code.
    also i did not get it completely regarding import can you please explain what i should do?

    Thanks for Your Help.

    Regards,
    Balaji
  • Hi,

    ok.. can you show the entire script contents of the groovy script step that you are running? Alternatively attach your soapUI project so we can see for ourselves!?

    regards,

    /Ole
    eviware.com
  • sirba01's avatar
    sirba01
    Occasional Contributor
    Hi,

    I have attached the SOAP UI project, and the jar which i am placed in my ext folder.

    Thanks,
    Balaji
  • sirba01's avatar
    sirba01
    Occasional Contributor
    Sorry, I was not able to attach my selenium-java-client-driver.jar
  • Hi,

    I'm facing similar problem.

    My project needs to execute a groovy script which performs actions on a browser and I have used selenium's 'selenium-java-client-driver.jar' in my soapUI project to achieve this (by placing the jar in C:\Program Files\eviware\soapUI-4.0.0\bin\ext). But when I execute the script it throws the following error -

    Thu Jul 28 11:13:21 IST 2011:ERROR:groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class com.example.tests.Untitled. Reason: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@6864d6' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'
    groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class com.example.tests.Untitled. Reason: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@6864d6' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'
    at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:430)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:743)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:770)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:761)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:148)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
    at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
    at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@6864d6' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'
    at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:331)
    at org.codehaus.groovy.reflection.CachedField.setProperty(CachedField.java:65)
    at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2356)
    at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3312)
    at org.codehaus.groovy.runtime.InvokerHelper.setProperties(InvokerHelper.java:450)
    at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:427)
    ... 10 more
    Thu Jul 28 11:48:41 IST 2011:ERROR:groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class com.example.tests.Untitled. Reason: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@6864d6' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'
    groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class com.example.tests.Untitled. Reason: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@6864d6' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'
    at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:430)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:743)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:770)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:761)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:148)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
    at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
    at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@6864d6' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'
    at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:331)
    at org.codehaus.groovy.reflection.CachedField.setProperty(CachedField.java:65)
    at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2356)
    at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3312)
    at org.codehaus.groovy.runtime.InvokerHelper.setProperties(InvokerHelper.java:450)
    at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:427)
    ... 10 more

    Can somebody please help me in resoling this problem?

    I have attached the project file and the jar file I have used to execute the Groovy script.

    Thanks,
    Shashi
  • Hi,
    Same problem for my company... Any news of the solution by a nightly version ?
  • Hi,

    hmm.. try adding the following line to your code:

    log = java.util.logging.Logger.getLogger( "some logger" )

    which will set the log object to a something that seems to be expected..

    Does that help?

    regards,

    /Ole
    SmartBear Software
  • I am running soupui with groovy script, but when i run it is giving this error "GroovyCastException: Cannot cast object 'com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcRequest@f653852' with class 'com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcRequest' to class 'com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequest'"

    Plz suggest solution.