Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

groovy.lang.MissingMethodException when calling withHttp() from a service #21

Description

Service class:

class GeoCoderService {
    def getLatLong(String address) {
        def result = null
        withHttp(uri: "http://maps.googleapis.com") {
            def html = get(path : '/maps/api/geocode/json', query : [address:address])
            if ( html.results != null && html.results.size() > 0 ) {
                def partial = html.results[0]
                if ( partial.geometry != null && partial.geometry.location != null) {
                    def lat = partial.geometry.location.lat
                    def lng = partial.geometry.location.lng
                    result = [lat:Double.valueOf(lat.toString()), lng:Double.valueOf(lng.toString())]
                }
            }
        }
        return result
    }
}

Controller class:

class GeneralController {

    def geoCoderService

    def index = {
        render (view: "index")
    }

    def test = {
        def point = geoCoderService.getLatLong('1600 Amphitheatre Pkwy, Mountain View, CA 94043')
        render "latitude = ${point.lat}"
        render "longitude = ${point.lng}"
    }
}

Exception:

Caused by: groovy.lang.MissingMethodException: No signature of method: package.GeoCoderService.withHttp() is applicable for argument types: (java.util.LinkedHashMap, package.GeoCoderService$_getLatLong_closure1) values: [[uri:http://maps.googleapis.com], package.GeoCoderService$_getLatLong_closure1@5ad666a2]
        at package.GeoCoderService.getLatLong(GeoCoderService.groovy:6) ~[main/:na]
        at package.GeneralController$_closure2.doCall(GeneralController.groovy:12) ~[main/:na]
        ... 3 common frames omitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions