restfulapi / restful-api

Grails plugin to facilitate exposing non-trivial RESTful APIs
Apache License 2.0
52 stars 27 forks source link

Allow subclasses of RestfulApiController #25

Open Nathan-Smith opened 9 years ago

Nathan-Smith commented 9 years ago

Since groovy closures run in the context of the current class (sub-class) any private properties or methods in the superclass are inaccessible within the closure.

context.GrailsContextLoaderListener Error initializing the application: No such property: handlerConfig for class: com.example.SubClassRestfulApiController
groovy.lang.MissingPropertyException: No such property: handlerConfig for class: com.example.SubClassRestfulApiController
    at org.codehaus.groovy.grails.plugins.web.api.ControllerTagLibraryApi.propertyMissing(ControllerTagLibraryApi.java:121)
    at com.example.SubClassRestfulApiController.propertyMissing(SubClassRestfulApiController.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaClassImpl.invokeMissingProperty(MetaClassImpl.java:874)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1853)
    at groovy.lang.ExpandoMetaClass.getProperty(ExpandoMetaClass.java:1140)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3690)
    at groovy.lang.ExpandoMetaClass.getProperty(ExpandoMetaClass.java:1152)
    at net.hedtech.restfulapi.RestfulApiController.getProperty(RestfulApiController.groovy)
    at com.example.SubClassRestfulApiController.getProperty(SubClassRestfulApiController.groovy)
    at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:168)
    at groovy.lang.Closure.getPropertyTryThese(Closure.java:321)
    at groovy.lang.Closure.getPropertyOwnerFirst(Closure.java:315)
    at groovy.lang.Closure.getProperty(Closure.java:304)
    at net.hedtech.restfulapi.RestfulApiController$_init_closure11.getProperty(RestfulApiController.groovy)
    at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
    at net.hedtech.restfulapi.RestfulApiController$_init_closure11.doCall(RestfulApiController.groovy:194)
chasdev commented 9 years ago

Could you provide some background on why you have a need to subclass the controller? Thanks.