grails-plugins / grails-rest-client-builder

REST client plugin that uses Spring's RestTemplate
http://grails.org/plugin/rest-client-builder
Apache License 2.0
65 stars 32 forks source link

URI Not Absolute #2

Open kehn opened 12 years ago

kehn commented 12 years ago

I'm getting the following stacktrace:

errors.GrailsExceptionResolver IllegalArgumentException occurred when processing request: [GET] /app/recommend
URI is not absolute. Stacktrace follows:
java.lang.IllegalArgumentException: URI is not absolute
    at java.net.URI.toURL(URI.java:1080)
    at grails.plugins.rest.client.RestBuilder.doRequestInternal(RestBuilder.groovy:93)
    at grails.plugins.rest.client.RestBuilder.get(RestBuilder.groovy:53)
    at com.citelighter.RecommendController$_closure1$$ENSn3KFE.doCall(RecommendController.groovy:12)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

Using this code (snippet):

def resp = new RestBuilder();
def r = resp.get("http://grails.org/api/v1.0/plugin/acegi/");
resp.json instanceof JSONObject;
resp.json.name = "acegi";

This error does not happen if I remove the JSON lines and instead I get a plain text response back.

hocondoimeo commented 11 years ago

I've tested above code, it's still worked with Grails 2.2.1

vacax commented 10 years ago

I have this problem in grails 2.2.3

LeeGDavis commented 10 years ago

I have this same problem in grails 2.4.2

def index(Integer max) {
        (new RestBuilder()).rest.get("http://localhost:8080/eca-proto-server/api/animal") {
            acceptType  MediaType.APPLICATION_JSON
        }
    }
2014-07-08 10:27:12,571 [http-bio-8080-exec-3] ERROR errors.GrailsExceptionResolver  - IllegalArgumentException occurred when processing request: [GET] /eca-proto-server/api/animal
URI is not absolute. Stacktrace follows:
Message: URI is not absolute
    Line | Method
->> 1095 | toURL              in java.net.URI
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    308 | invokeRestTemplate in grails.plugins.rest.client.RestBuilder
|    273 | doRequestInternal  in     ''
|    261 | doRequestInternal  in     ''
|    106 | get . . . . . . .  in     ''
|     17 | index              in com.drc.app.v1.AnimalController
|    177 | doFilter . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter           in grails.plugin.cache.web.filter.AbstractFilter
|     82 | doFilter . . . . . in com.brandseye.cors.CorsFilter
|   1145 | runWorker          in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run                in java.lang.Thread