Grails 2.3.3 REST with @Resource result in HTTP 500?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 2.3.3 REST with @Resource result in HTTP 500?

JohanSandqvist
Just getting started with Grails and followed the instructions here to get a simple REST service up and running: http://grails.org/doc/2.3.3/guide/webServices.html#REST

Created a domain class as:

package rester

import grails.rest.*

@Resource(uri = '/books', formats = ['json', 'xml'])
class Book {

    String title
       
    static constraints = {
    }
}

Also added a Book using BootStrap.groove as:
    def init = { servletContext ->
                new Book(title:"neuromancer").save()
    }


I'm using GGTS 3.4 and downloaded Grails 2.3.3 and added it as a Grails runtime plus installed the groovy compiler 2.1. I deploy the grails app to the included TC 2.9.3 server and run it from within GGTS.

All GETs work fine and return HTTP 200 with the data but every time I try to POST or DELETE using curl or RESTClient addon in FF I get an HTTP 500 but the object IS saved/deleted and a subsequent GET will show the result.

The server output in the console says:

2013-12-06 16:40:24,402 [tomcat-http--9] ERROR errors.GrailsExceptionResolver  - GroovyCastException occurred when processing request: [POST] /rester/books
Cannot cast object 'rester.BookController$_save_closure5@cfac44a' with class 'rester.BookController$_save_closure5' to class 'rester.BookController'. Stacktrace follows:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'rester.BookController$_save_closure5@cfac44a' with class 'rester.BookController$_save_closure5' to class 'rester.BookController'
        at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200)
        at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

What am I missing here?
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.3.3 REST with @Resource result in HTTP 500?

bobbywarner
Hi Johan,

First, I want to let you know that your message didn't actually go through to the list... you must not actually be subscribed.  I can see it on the Nabble UI though.

For your question, can you please share the CURL command you used for the POST/DELETE requests?


Thanks,
Bobby
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.3.3 REST with @Resource result in HTTP 500?

JohanSandqvist
Ok, thanks for responding.

Here is the curl command:
curl -i -X POST -H "Content-Type: application/json" -d '{"title":"Along Came A Spider"}' localhost:8080/rester/books


From: "bobbywarner [via Grails]" <[hidden email]>
Date: Saturday, December 7, 2013 8:13 AM
To: "Sandqvist, Johan (STM)" <[hidden email]>
Subject: Re: Grails 2.3.3 REST with @Resource result in HTTP 500?

Hi Johan,

First, I want to let you know that your message didn't actually go through to the list... you must not actually be subscribed.  I can see it on the Nabble UI though.

For your question, can you please share the CURL command you used for the POST/DELETE requests?


Thanks,
Bobby


If you reply to this email, your message will be added to the discussion below:
http://grails.1312388.n4.nabble.com/Grails-2-3-3-REST-with-Resource-result-in-HTTP-500-tp4652266p4652275.html
To unsubscribe from Grails 2.3.3 REST with @Resource result in HTTP 500?, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.3.3 REST with @Resource result in HTTP 500?

shaunnb
Getting the same thing here on PUT's.