Hi,
I needed to move the API Resource getHelp out of my main API class so I can use the standard REST root GET for a readAll type listing. I created a class in the same package as the API itself but am having class-loader issues using the listingClass parameter.
package com.s.g.queuemanager
@Path('/api/job')
@Api(value = "/api/job", description = "Job API", listingPath = "/api/resources/job")
@Consumes(['application/xml','application/json'])
@Produces(['application/xml','application/json'])
class JobCollectionResource {
...
}
-----------------
package com.stationx.genepool.queuemanager
@Path("/api/resources/job")
@Api(value = "/api/job", description = "Operations about Jobs",
listingPath = "/api/resources/job", listingClass = "com.s.g.queuemanager.JobCollectionResource")
@Produces(["application/json", "application/xml"])
class JobCollectionResourceAPIListing extends JavaHelp {}
-------
Here's the exception:
ERROR errors.GrailsExceptionResolver - ClassNotFoundException occurred when processing request: [GET] /api/resources/job - parameters:
api_key: special-key
class com.s.g.queuemanager.JobCollectionResource not found. Stacktrace follows:
Message: class com.s.g.queuemanager.JobCollectionResource not found
Line | Method
->> 46 | loadClass in com.wordnik.swagger.core.SwaggerContext$
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 66 | getHelp in com.wordnik.swagger.jaxrs.JavaHelp
| -1 | getHelp . . . . . . . . . . . . in com.s.g.queuemanager.JobCollectionResourceAPIListing
| -2 | invoke0 in sun.reflect.NativeMethodAccessorImpl
| 39 | invoke . . . . . . . . . . . . in ''
| 25 | invoke in sun.reflect.DelegatingMethodAccessorImpl
| 597 | invoke . . . . . . . . . . . . in java.lang.reflect.Method
| 1231 | jlrMethodInvoke in com.springsource.loaded.ri.ReflectiveInterceptor
| 60 | invoke . . . . . . . . . . . . in com.sun.jersey.spi.container.JavaMethodInvokerFactory$1
And here's a listing showing the classes do exist (I am using grails but that should not be a factor?) :-
$ ls -l WEB-INF/classes/com/s/g/queuemanager/
...
-rw-r--r-- 1 mike staff 9944 Oct 29 19:07 JobCollectionResource.class
-rw-r--r-- 1 mike staff 6950 Oct 30 06:19 JobCollectionResourceAPIListing.class
-rw-r--r-- 1 mike staff 8184 Oct 29 14:44 JobResource.class
-rw-r--r-- 1 mike staff 8059 Oct 27 07:02 JobResourceService.class
When I tried it with @Singleton in the APIListing class (as I've seen in several examples) I got a different error:
Caused by BeanInstantiationException: Could not instantiate bean class [com.s.g.queuemanager.JobCollectionResourceAPIListing]: Constructor threw exception; nested exception is java.lang.RuntimeException: Can't instantiate singleton com.s.g.queuemanager.JobCollectionResourceAPIListing. Use com.s.g.queuemanager.JobCollectionResourceAPIListing.instance
->> 162 | instantiateClass in org.springframework.beans.BeanUtils
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 108 | instantiate in org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory$1
| 990 | instantiateBean . . . . . . . . in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
| 943 | createBeanInstance in ''
| 485 | doCreateBean . . . . . . . . . in ''
| 130 | doCreateBean in org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory
| 456 | createBean . . . . . . . . . . in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
| 313 | doGetBean in org.springframework.beans.factory.support.AbstractBeanFactory
| 197 | getBean . . . . . . . . . . . . in ''
| 1097 | getBean in org.springframework.context.support.AbstractApplicationContext
| 235 | getInstance . . . . . . . . . . in com.sun.jersey.spi.spring.container.SpringComponentProviderFactory$SpringManagedComponentProvider
| 150 | getInstance in com.sun.jersey.server.impl.component.IoCResourceFactory$PerRequestWrapper
| 238 | getResource . . . . . . . . . . in com.sun.jersey.server.impl.application.WebApplicationContext