Forum Discussion

白夜有点黑's avatar
白夜有点黑
Contributor
5 years ago
Solved

ERROR:groovy.lang.MissingMethodException: No signature of method

I have groovy util class as below:

 

 

package com.hypers.test.apitest.util

import groovy.sql.Sql

class DataBaseUtil {

    static def database

    static def connectDB(def url, def username, def password, def driver){
        database = Sql.newInstance(url,username,password,driver)
    }

    static def queryData(def sqlcommand){
        database.rows(sqlcommand)
    }

    static def queryData(def sqlcommand, def offset, def pageSize){
        database.rows(sqlcommand, offset, pageSize)
    }

    static def getFirstRow(def sqlcommand){
        database.firstRow(sqlcommand)
    }

    static def updateData(def sqlcommand){
        database.executeUpdate(sqlcommand)
    }

    static def insertData(def sqlcommand){
        database.executeInsert(sqlcommand)
    }

    static def deleteData(def sqlcommand){
        database.execute(sqlcommand)
    }

    static def closeDB(){
        database.close()
    }
}

 

 

I copied it to SoapUI for a reference, like:

 

 

package com.hypers.test.apitest.util

def JDBC_URL = context.expand( '${#Project#JDBC_URL}' )
def DB_UserName = context.expand( '${#Project#DB_UserName}' )
def DB_Password = context.expand( '${#Project#DB_Password}' )
def DB_Driver = context.expand( '${#Project#DB_Driver}' )

def sqlcommand = "SELECT id From configs_account Where name = 'APITEST_NewAccount_ValidData_ACTIVE'"

DataBaseUtil.connectDB(JDBC_URL, DB_UserName, DB_Password, DB_Driver)
DataBaseUtil.queryData(sqlcommand)
DataBaseUtil.getFirstRow(sqlcommand)

 

 

It works well with queryData method, but it's throws exception with getFirstRow method, I really can't figure out what's going on and get blocked for a very long time, please help to have a look, thanks.

 

Exception as below:

Tue Jul 23 15:48:47 CST 2019:ERROR:groovy.lang.MissingMethodException: No signature of method: static com.hypers.test.apitest.util.DataBaseUtil.getFirstRow() is applicable for argument types: (java.lang.String) values: [SELECT id From configs_account Where name = 'APITEST_NewAccount_ValidData_ACTIVE']
   groovy.lang.MissingMethodException: No signature of method: static com.hypers.test.apitest.util.DataBaseUtil.getFirstRow() is applicable for argument types: (java.lang.String) values: [SELECT id From configs_account Where name = 'APITEST_NewAccount_ValidData_ACTIVE']
   	at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1373)
   	at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1359)
   	at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:50)
   	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
   	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
   	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
   	at com.hypers.test.apitest.util.DBUtil.getFirstRow(Script10.groovy:38)
   	at com.hypers.test.apitest.util.DBUtil$getFirstRow.call(Unknown Source)
   	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
   	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
   	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
   	at Script18.run(Script18.groovy:10)
   	at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
   	at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:79)
   	at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:138)
   	at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   	at java.lang.Thread.run(Unknown Source)
  • Nastya_Khovrina's avatar
    Nastya_Khovrina
    5 years ago

    白夜有点黑,

     

    Did you change the definition of sqlcommand as nmrao suggested?

    def sqlcommand = 'SELECT id From configs_account Where name = \'APITEST_NewAccount_ValidData_ACTIVE\''

    Do you get the same error now? Can you please provide us with the new stack trace?

9 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Please try with below change (replace the respective statement in your script)

    def sqlcommand = 'SELECT id From configs_account Where name = \'APITEST_NewAccount_ValidData_ACTIVE\''
      • Melissa's avatar
        Melissa
        Occasional Visitor

        Replace "static method" of  JDBC Connection class with “construction method” ,it worked!