budjb / grails-jaxrs Goto Github PK
View Code? Open in Web Editor NEWThis project forked from krasserm/grails-jaxrs
JAX-RS Plugin for Grails
This project forked from krasserm/grails-jaxrs
JAX-RS Plugin for Grails
From @confile on August 28, 2014 21:52
I am not sure if I got it right. I want to create a HTTP Session when a request is comming to my REST api. What I did in Grails conf folder is creating a Filter as:
class SessionFilters {
def filters = {
createSession(controller: '*', action: '*') {
before = {
def session = request.getSession(true) //create session if not exists
}
}
showInActionName(action: 'show', find: true) {
before = {
session.currentLocation = request.forwardURI - request.contextPath
}
}
}
}
It works well wir HTTP request meaning if I request a view which is served by a Grails Controller.
But when it comes to REST APi I am not sure I a session is created correctly. I want to create a session because I want to track which users are currently online and logged in.
My question. Is this the correct way of doing this or would you suggest another way?
Copied from original issue: krasserm#55
From @confile on April 10, 2014 15:21
Is it possible to set cache headers in the response?
HTTP headers: cache-control, last-modified & etag
Copied from original issue: krasserm#48
From @hotmeatballsoup on May 1, 2015 13:47
Grails 3 is here - can we confirm that this plugin supports it in full?
Copied from original issue: krasserm#63
From @satb on March 4, 2014 3:59
Adding this plugin is throwing an error like this
Caused by NoClassDefFoundError: Could not initialize class com.tinkerpop.rexster.client.RexProClientFilter
Without the plugin everything works fine and the same class can be loaded without a problem. What could be wrong?
Using grails 2.3
Build.config is very simple
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
// run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
mavenRepo 'http://maven.restlet.org'
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.27'
// runtime 'org.postgresql:postgresql:9.3-1100-jdbc41'
runtime 'com.tinkerpop.rexster:rexster-protocol:2.5.0-SNAPSHOT'
runtime 'org.postgresql:postgresql:9.3-1100-jdbc41'
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.50"
// plugins for the compile step
compile ":scaffolding:2.0.1"
compile ':cache:1.1.1'
// plugins needed at runtime but not for compilation
runtime ":hibernate:3.6.10.7" // or ":hibernate4:4.1.11.6"
runtime ":database-migration:1.3.8"
runtime ":jquery:1.10.2.2"
runtime ":resources:1.2.1"
runtime ':jaxrs:0.10'
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0.1"
//runtime ":cached-resources:1.1"
//runtime ":yui-minify-resources:0.1.5"
}
}
Simply commenting out the jaxrs: 0.10 will cause the loading problem to go away. Is it a class loader issue?
Copied from original issue: krasserm#47
Hi Bud,
I've been using the new plugins perfectly (using IDE and grails run-app) but its now time to deploy so when creating a war file and starting up I'm getting the following stacktrace. Have you come across this? Tomcat 8.0.35 Java 8 91-b14
2016-06-02 15:49:08 ERROR grails.boot.GrailsApp - Application startup failed
java.lang.NullPointerException: null
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.lookupInServletContext(CDIComponentProviderFactoryInitializer.java:130) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.lookup(CDIComponentProviderFactoryInitializer.java:89) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:70) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) ~[jersey-servlet-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) ~[jersey-servlet-1.19.jar:1.19]
at javax.servlet.GenericServlet.init(GenericServlet.java:158) ~[servlet-api.jar:3.1.FR]
at javax.servlet.Servlet$init.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-2.4.5.jar:2.4.5]
at org.grails.plugins.jaxrs.core.JaxrsContext.init(JaxrsContext.groovy:102) ~[jaxrs-core-3.0.2.jar:na]
at org.grails.plugins.jaxrs.core.JaxrsContext$init.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) ~[groovy-2.4.5.jar:2.4.5]
at org.grails.plugins.jaxrs.JaxrsCoreGrailsPlugin.doWithApplicationContext(JaxrsCoreGrailsPlugin.groovy:154) ~[jaxrs-core-3.0.2.jar:na]
at org.grails.plugins.DefaultGrailsPlugin.doWithApplicationContext(DefaultGrailsPlugin.java:524) ~[grails-core-3.0.16.jar:3.0.16]
at org.grails.plugins.AbstractGrailsPluginManager.doPostProcessing(AbstractGrailsPluginManager.java:229) ~[grails-core-3.0.16.jar:3.0.16]
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:229) ~[grails-core-3.0.16.jar:3.0.16]
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy) ~[grails-core-3.0.16.jar:3.0.16]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151) ~[spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128) ~[spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331) ~[spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:775) ~[spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:139) ~[spring-boot-1.2.7.RELEASE.jar:1.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483) ~[spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:117) ~[spring-boot-1.2.7.RELEASE.jar:1.2.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:689) ~[spring-boot-1.2.7.RELEASE.jar:1.2.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) ~[spring-boot-1.2.7.RELEASE.jar:1.2.7.RELEASE]
at grails.boot.GrailsApp.run(GrailsApp.groovy:55) [grails-core-3.0.16.jar:3.0.16]
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:134) [spring-boot-1.2.7.RELEASE.jar:1.2.7.RELEASE]
at org.grails.boot.context.web.GrailsAppServletInitializer.createRootApplicationContext(GrailsAppServletInitializer.groovy:57) [grails-web-boot-3.0.16.jar:3.0.16]
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:81) [spring-boot-1.2.7.RELEASE.jar:1.2.7.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) [spring-web-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5261) [catalina.jar:8.0.35]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [catalina.jar:8.0.35]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) [catalina.jar:8.0.35]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) [catalina.jar:8.0.35]
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940) [catalina.jar:8.0.35]
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816) [catalina.jar:8.0.35]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_91]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_91]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_91]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_91]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
Hi,
I am trying to create a resource that processes a File via a POST request, see my fork of the plugin, with the relevant TestMultipartResource.
I have an integration test based on the example in issue 21 which PASSES.
But when I am running the app and try to send the file via curl (see the commented command in the resource class) I am getting a 400 error. What am I doing wrong?
From @infomio on September 16, 2013 9:6
Hi,
I'm using Grails 2.0.1 and jaxrs 0.6. I downloaded “jersey-multipart.jar” (add code "compile 'com.sun.jersey.contribs:jersey-multipart:1.8'" in file BuildConfig.groovy).
I made a file upload service based on this tutorial: http://www.mkyong.com/webservices/jax-rs/file-upload-example-in-jersey/
Then I send a POST request with Postman (an add on in google chrome) and receive an error:
java.io.IOException: Stream closed
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:312)
at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:200)
at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:976)
at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:886)
at java.io.InputStream.read(InputStream.java:85)
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:96)
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:66)
at org.apache.commons.fileupload.MultipartStream.readBodyData(MultipartStream.java:592)
at org.apache.commons.fileupload.MultipartStream.discardBodyData(MultipartStream.java:618)
at org.apache.commons.fileupload.MultipartStream.skipPreamble(MultipartStream.java:637)
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:984)
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.(FileUploadBase.java:965)
at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:331)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:351)
at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:156)
at org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:139)
at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.getResolvedRequest(DefaultUrlMappingInfo.java:180)
at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.tryMultipartParams(DefaultUrlMappingInfo.java:170)
at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.checkDispatchAction(DefaultUrlMappingInfo.java:147)
at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.getActionName(DefaultUrlMappingInfo.java:128)
at org.codehaus.groovy.grails.web.mapping.AbstractUrlMappingInfo.populateParamsForMapping(AbstractUrlMappingInfo.java:94)
at org.codehaus.groovy.grails.web.mapping.AbstractUrlMappingInfo.configure(AbstractUrlMappingInfo.java:44)
at org.codehaus.groovy.grails.web.servlet.ErrorHandlingServlet.doDispatch(ErrorHandlingServlet.java:102)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:200)
at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:151)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:369)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:99)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.oauth2.provider.filter.OAuth2ProtectedResourceFilter.doFilter(OAuth2ProtectedResourceFilter.java:67)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.oauth2.provider.filter.OAuth2ExceptionHandlerFilter.doFilter(OAuth2ExceptionHandlerFilter.java:50)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.oauth2.provider.filter.EndpointValidationFilter.doFilter(EndpointValidationFilter.java:47)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
at org.codehaus.groovy.grails.plugins.springsecurity.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:40)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.codehaus.groovy.grails.plugins.springsecurity.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:79)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:473)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:455)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:324)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:193)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
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:662)
Please help me solve this problem.
Thanks
Copied from original issue: krasserm#28
Iam using grails jaxrs plugin with Grails 3.2.2, Groovy Version: 2.4.7 and JVM Version: 1.8.0_101.
dependencies {
...
compile 'org.grails.plugins:jaxrs-restlet:3.0.4'
...
}
then, follow the 9.2 Scaffodlding Domain of JAX-RS Project - Reference Documentation
grails create-domain-class com.ariel.person
Open the generated Person.groovy file (under grails-app/domain) and add two properties, firstName and lastName.
grails generate-resources com.ariel.Person
grails run-app
But I got run time error org.springframework.boot.SpringApplication - Application startup failed.
|Resolving Dependencies. Please wait...
CONFIGURE SUCCESSFUL
Total time: 3.539 secs
|Running application...
ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at org.grails.web.mapping.ResponseCodeMappingData.(ResponseCodeMappingData.java:31)
at org.grails.web.mapping.DefaultUrlMappingEvaluator$UrlMappingBuilder.createUrlMappingData(DefaultUrlMappingEvaluator.java:1056)
at org.grails.web.mapping.DefaultUrlMappingEvaluator$UrlMappingBuilder._invoke(DefaultUrlMappingEvaluator.java:643)
at org.grails.web.mapping.DefaultUrlMappingEvaluator$UrlMappingBuilder.invokeMethodClosure(DefaultUrlMappingEvaluator.java:376)
at org.grails.web.mapping.DefaultUrlMappingEvaluator$UrlMappingBuilder.invokeMethod(DefaultUrlMappingEvaluator.java:366)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:430)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:371)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:430)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:369)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:82)
at org.grails.plugins.jaxrs.core.JaxrsUtil$_configureMappings_closure6$_closure9.doCall(JaxrsUtil.groovy:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:430)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.grails.plugins.jaxrs.core.JaxrsUtil$_configureMappings_closure6.doCall(JaxrsUtil.groovy:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:430)
at org.grails.web.mapping.DefaultUrlMappingEvaluator.evaluateMappings(DefaultUrlMappingEvaluator.java:158)
at org.grails.web.mapping.DefaultUrlMappingsHolder.addMappings(DefaultUrlMappingsHolder.java:123)
at org.grails.web.mapping.mvc.AbstractGrailsControllerUrlMappings.addMappings(AbstractGrailsControllerUrlMappings.groovy:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy85.addMappings(Unknown Source)
at grails.web.mapping.UrlMappings$addMappings.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.grails.plugins.jaxrs.core.JaxrsUtil.configureMappings(JaxrsUtil.groovy:122)
at org.grails.plugins.jaxrs.core.JaxrsUtil$configureMappings$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.grails.plugins.jaxrs.JaxrsCoreGrailsPlugin.doWithApplicationContext(JaxrsCoreGrailsPlugin.groovy:156)
at org.grails.plugins.DefaultGrailsPlugin.doWithApplicationContext(DefaultGrailsPlugin.java:523)
at org.grails.plugins.AbstractGrailsPluginManager.doPostProcessing(AbstractGrailsPluginManager.java:224)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:246)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:877)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at grails.boot.GrailsApp.run(GrailsApp.groovy:79)
at grails.boot.GrailsApp.run(GrailsApp.groovy:381)
at grails.boot.GrailsApp.run(GrailsApp.groovy:370)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at ariel.Application.main(Application.groovy:8)
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':bootRun'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error |
Failed to start server (Use --stacktrace to see the full trace)
Process finished with exit code 1
When using generate resources on a domain class, the base resources no longer function.
Using generated resources and spring security rest. My original pull request fixed the crashing issue to at least get it to start but the side effect was these base resources don't work.
// Collection
package users
import grails.plugin.springsecurity.annotation.Secured
import static org.grails.plugins.jaxrs.response.Responses.*
import javax.ws.rs.Consumes
import javax.ws.rs.GET
import javax.ws.rs.Produces
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.POST
import javax.ws.rs.core.Response
@Path('/api/user')
@Consumes(['application/xml','application/json'])
@Produces(['application/xml','application/json'])
class UserCollectionResource {
def userResourceService
@POST
Response create(User dto) {
created userResourceService.create(dto)
}
@GET
@Secured([UserService.ROLE_ADMIN])
Response readAll() {
ok userResourceService.readAll()
}
@Secured([UserService.ROLE_ADMIN])
@Path('/{id}')
UserResource getResource(@PathParam('id') Long id) {
new UserResource(userResourceService: userResourceService, id:id)
}
}
// Base
package users
import grails.plugin.springsecurity.annotation.Secured
import javax.ws.rs.Path
import static org.grails.plugins.jaxrs.response.Responses.*
import javax.ws.rs.Consumes
import javax.ws.rs.DELETE
import javax.ws.rs.GET
import javax.ws.rs.Produces
import javax.ws.rs.PUT
import javax.ws.rs.core.Response
@Consumes(['application/xml','application/json'])
@Produces(['application/xml','application/json'])
class UserResource {
def userResourceService
def id
@GET
@Secured([UserService.ROLE_ADMIN])
Response read() {
ok userResourceService.read(id)
}
@PUT
Response update(User dto) {
dto.id = id
ok userResourceService.update(dto)
}
@DELETE
void delete() {
userResourceService.delete(id)
}
}
Request list example:
curl -i -H "Accept: application/json" -X GET -H "Authorization: Bearer XXX" "http://localhost:8080/api/user"
HTTP/1.1 200
X-Application-Context: application:development
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 31 Jan 2017 12:01:58 GMT
[{"id":2,"accountExpired":false,"accountLocked":false,"emailAddress":"[email protected]","enabled":true,"password":"$2a$10$gGCLHcmOL0xOHRe/DU88ueMvUEa/SAOi49VG.N0i2SBRJV75gZ6UC","passwordExpired":false}]
Request user ID 2 as provided:
curl -i -H "Accept: application/json" -X GET -H "Authorization: Bearer XXX" "http://localhost:8080/api/user/2"
HTTP/1.1 404
X-Application-Context: application:development
Content-Type: application/json;charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Date: Tue, 31 Jan 2017 12:02:01 GMT
{"message":"Not Found","error":404}
Cant apply URL Mapping like Grails 2.x
From @lakshmipmandava on August 5, 2015 9:12
We are trying to get the actual uri in Grails filter
testUris(uri:'/api/**') {
before = {
println("before ----------------"+request.getRequestURI())
// do some preprocessing
}
after = {
println("sdafter ----------------"+request.getRequestURI())
// do some postprocessing
}
}
using above code. but its it printing /grails/jaxrs.dispatch instead of api/v1/login/1234
Copied from original issue: krasserm#66
From @murphy-paul on September 17, 2013 3:23
It appears that the plugin is appending and '/' to the end of URLS when causes jersey to fail to when resolving the matrix params.
See MatrixParamInjectableProvider.getValue. This method will only look at the last Path segment. And an extra path segment is added because of the '/'
See UriComponent.decodePath at line 595.
e = path.indexOf('/', s) will cause the matrix params to be resolve in the do while loop. After the loop the if(s < path.length()) condition is false and an extra Empty Path segment is added.
Great plugin by the way.
Copied from original issue: krasserm#29
From @davidecavestro on July 1, 2014 8:36
At the moment we have two main concerns about jaxrs implementation choice:
Both of them are caused by the fact that the plugin includes some jaxrs implementation specific sources.
In order to mitigate the first one we could see if restlet artifacts become available on maven central (see restlet/restlet-framework-java#481).
For the second one I've opened a dedicated thread to see if there's a way to control optional deps at application build time.
In case that's not a viable solution, I feel we have two alternatives:
IMHO the former solution is cleaner, but it would introduce some additional complexity in plugin management (i.e. 3 github projects instead of the actual one, issue tracking and so on).
Copied from original issue: krasserm#53
From @srmelody on June 27, 2013 22:5
Jersey 2.0 is out:
https://jersey.java.net/
It would be great for this plugin to support the 2.0 version of Jersey.
Copied from original issue: krasserm#19
running the app in dev via grails run-app works fine, but trying to do grails war (or gradle war) ends up
with the following (removing a lot of intermediate lines of the stack trace for brevity)
I've tried specifically adding a dependency to the jersey core with no luck. Google only seems to point me in the direction of some inconsistency of mixing groovy and java compilation, which doesn't seem to be my issue since this project doesn't have any java classes.
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':webapp:compileGroovy'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
Caused by: java.lang.ExceptionInInitializerError
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:164)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:52)
at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.java:53)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
Caused by: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl
switching to restlet at least seems to compile though.
From @daptordarattler on May 7, 2015 14:14
I have a date property on a domain model
Consignment{
String description
Date dateDone
Date dateCreated
Date lastUpdated
}
Any time I update the dateDone from the client with javascript using code
consignment.dateDone = new Date().toISOString()
it is nulled in the resource code before even getting to the service operations
I have no Idea why. Its got me pulling out my hair all day.
Copied from original issue: krasserm#64
From @confile on November 29, 2013 16:2
When do you recommend to use your plugin in scope:
org.grails.jaxrs.resource.scope='singleton'
Copied from original issue: krasserm#37
From @LexeY4eg on October 1, 2013 16:10
It would be nice to have a way to override scaffolding templates without plugin sources modification.
Copied from original issue: krasserm#32
From @spirylics on September 15, 2014 15:9
I would like make that :
@GET
@JsonView(Views.Name.class)
List<User> list(@Context UriInfo uriInfo) {
User.list(uriInfo.getQueryParameters())
}
But @JSONVIEW is not interpreted ; all user fields are returned.
Copied from original issue: krasserm#58
I'm experiencing jersey being initialized twice. First time from JaxrsListener
, second time from JaxrsCoreGrailsPlugin
. This really slows down the startup of the app.
From @slackfarmer on January 14, 2015 22:6
I am experiencing two issues with this plugin. Most of it, seems to be some kind of dependency hell.
1.) When I try to demarshal custom jax annotated objects for json I am getting the following:
2015-01-14 14:55:09,990 [http-bio-80-exec-4] ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - ClassNotFoundException occurred when processing request: [POST] /templateService/api/pageTemplates/test
org.codehaus.jackson.JsonFactory. Stacktrace follows:
java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:655)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:765)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:753)
at com.sun.jersey.json.impl.reader.JsonXmlStreamReader.create(JsonXmlStreamReader.java:110)
at com.sun.jersey.json.impl.Stax2JsonFactory.createReader(Stax2JsonFactory.java:137)
at com.sun.jersey.json.impl.Stax2JsonFactory.createReader(Stax2JsonFactory.java:127)
at com.sun.jersey.json.impl.BaseJSONUnmarshaller.createXmlStreamReader(BaseJSONUnmarshaller.java:116)
at com.sun.jersey.json.impl.BaseJSONUnmarshaller.unmarshalJAXBElementFromJSON(BaseJSONUnmarshaller.java:111)
at com.sun.jersey.json.impl.BaseJSONUnmarshaller.unmarshalFromJSON(BaseJSONUnmarshaller.java:100)
at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider.readFrom(JSONRootElementProvider.java:154)
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:111)
at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:490)
at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:123)
at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:86)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:153)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:203)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715)
2.) The 0.11 version of the jaxrs plugin is not pulling it's dependencies automatically.
I have to add the following to my BuildConfig.groovy so that it can resolve the required dependencies.
String restletVersion = '2.1.4'
String jerseyVersion = '1.18.1'
compile "org.restlet.gae:org.restlet:$restletVersion"
compile("org.restlet.gae:org.restlet.ext.servlet:$restletVersion") {
excludes 'org.restlet', 'servlet-api'
}
compile("com.sun.jersey:jersey-core:$jerseyVersion") {
excludes 'jaxb-api', 'jsr311-api', 'junit', 'mail', 'org.osgi.core'
}
compile("com.sun.jersey:jersey-servlet:$jerseyVersion") {
excludes 'ant', 'commons-io', 'javax.ejb', 'javax.servlet-api', 'jsp-api', 'junit', 'osgi_R4_core',
'persistence-api', 'weld-osgi-bundle'
}
compile("com.sun.jersey:jersey-server:$jerseyVersion") {
excludes 'asm', 'commons-io', 'jaxb-api', 'jsr250-api', 'junit', 'mail', 'osgi_R4_core'
}
compile("com.sun.jersey:jersey-json:$jerseyVersion") {
excludes 'jackson-core-asl', 'jackson-jaxrs', 'jackson-mapper-asl', 'jackson-xc', 'jaxb-impl', 'jettison', 'junit', 'org.eclipse.persistence.moxy'
}
compile("com.sun.jersey.contribs:jersey-spring:$jerseyVersion") {
excludes 'jaxb-impl', 'jsr250-api', 'junit', 'servlet-api', 'testng', 'spring-core', 'spring-beans',
'spring-context', 'spring-web', 'spring-aop'
}
compile('javax.ws.rs:jsr311-api:1.1.1') {
excludes 'junit'
}
Copied from original issue: krasserm#59
From @LexeY4eg on October 1, 2013 15:22
Please, add an extended WADL support, or advise another way how to generate documentation for REST services (javadoc support would be nice).
see: https://wikis.oracle.com/display/Jersey/HowToConfigureExtendedWADL
Thanks
Copied from original issue: krasserm#31
From @shnatyk on January 12, 2014 19:6
Hi,
I am beginner with Grails and struggling some problem with combining REST api and Spring Security for my web application (grails version: 2.2.4).
Before creating API I created registration and authentication system and all works fine. About REST, till now I have tried two ways, one according to documentation (http://www.grails.org/doc/2.2.x/guide/webServices.html), second by using JAX-RS plugin. In both ways I go thorugh all needed steps without problems till I try to test if any api's URL works, I always got this message in browser: "Sorry, you are not authorized to view this page", even if I am logged in as the admin (ROLE_ADMIN).
I tried to add some static rule or intercepturlmap to config.groovy file but nothing have helped.
Please help me, give any clues, suggestions, every reply very appreciated!
Seb
Copied from original issue: krasserm#40
From @stefaniebrunner on June 9, 2014 20:45
Hi, do you know how I can print or get out the content of a json-formatted POST request? My API received a json, but I don't know exactly how the structure of that json is. I tried a lot but I always reveive an error (a message body reader for Java class ... and Java type class was not found).
What can I do to find out what is in the request body? Thanks a lot.
Copied from original issue: krasserm#49
Use a deprecated package of spring
New class on
org.springframework.boot.web.servlet.ServletListenerRegistrationBean
Use
import org.springframework.boot.context.embedded.ServletListenerRegistrationBean
2017-05-13 12:20:17.196 ERROR --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/ServletListenerRegistrationBean
at org.grails.plugins.jaxrs.JaxrsCoreGrailsPlugin$_doWithSpring_closure1.doCall(JaxrsCoreGrailsPlugin.groovy:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:408)
at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:759)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:588)
at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:531)
at org.grails.plugins.DefaultGrailsPlugin.doWithRuntimeConfiguration(DefaultGrailsPlugin.java:559)
at org.grails.plugins.AbstractGrailsPluginManager.doRuntimeConfiguration(AbstractGrailsPluginManager.java:167)
at grails.boot.config.GrailsApplicationPostProcessor.postProcessBeanDefinitionRegistry(GrailsApplicationPostProcessor.groovy:171)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at grails.boot.GrailsApp.run(GrailsApp.groovy:83)
at grails.boot.GrailsApp.run(GrailsApp.groovy:388)
This is Grails 4.0.10 and OpenJDK8.
I have upgraded a Grails 2.5.4 application to 4.0.10 and on startup I get the following error:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is org.grails.core.exceptions.GrailsRuntimeException: Failed to introspect class: class org.grails.plugins.jaxrs.Application
The plugin hasn't been migrated to 4.x and I am unsure of how the application will need to be updated for this to work.
Are there plans to upgrade for Grails 4.x?
Can you suggest a migration plan if not?
From @trpedersen on August 26, 2013 6:27
Hi,
Thanks for the good work with this plugin - it is working well for us.
An improvement though - if a client programs sends through invalid JSON or XML then the JSONReader and XMLReader code falls over with an uncaught exception (e.g. JsonException) causing an HTTP 500 error back at the client. IMHO this should be instead caught and send back to the client as a BAD_REQUEST (or similar) message, rather than a server error.
The two ..readFrom methods should catch any exceptions raised during xml or json parsing and wrap them in a WebApplicationException with the appropriate Response+status+entity+type set.
I've worked around it by using ExceptionMappers for now..
Tim Pedersen
Copied from original issue: krasserm#25
From @confile on February 7, 2014 1:50
I want to use a security cookie sent on each request between the server and the client. Is it possible to access request header information in my Resource classes to extract the security cookie X-CSRF-Token?
The security cookie could be the cookie from the JSESSIONID. Is it possible to reject the request if the secure cookie does not match?
Thank you for help. I really like your plugin.
Copied from original issue: krasserm#44
From @vinod-bb on October 28, 2015 11:20
I am using grails jaxrs plugin with Grails 2.2.4
grails.project.dependency.resolution = {
plugins {
compile ':jaxrs:0.8'
}
}
During compilation of my Grails Application and i get the below error
/plugins/jaxrs-0.8/src/java/org/springframework/mock/web/DelegatingServletInputStream.java:39: error: DelegatingServletInputStream is not abstract and does not override abstract method setReadListener(ReadListener) in ServletInputStream public class DelegatingServletInputStream extends ServletInputStream {
Please help
Copied from original issue: krasserm#68
From @hakkanicko on January 28, 2014 14:33
Hi !
I have a weird issue. I have a domain class, like this :
class Test {
Date date
static constraints = {
}
}
And a REST resource like this :
@Path('/api/test')
class TestResource {
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
Response postTestRepresentation(Test tr) {
Response.ok(tr).build()
}
}
In my REST client, if I post a JSON object on /api/test like this :
{"date":"2014-01-28T15:56:37Z"}
I get this, and it's fine :
{
"class": "api.Test"
"id": null
"date": "2014-01-28T15:56:37Z"
}
But if I post a date with hours set to 12, like :
{"date":"2014-01-28T12:56:37Z"}
I get my hour digits unmarshalled to 00 and I get this :
{
"class": "api.Test"
"id": null
"date": "2014-01-28T00:56:37Z"
}
By the way, I use Grails 2.3.5 and jaxrs:0.10.
If anybody have an explanation or/and a workaround, it will be great :)
Thanks.
Copied from original issue: krasserm#42
From @confile on September 8, 2014 20:26
In my production environment I get the following error:
Sep 08, 2014 10:08:24 PM com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator attachTypes
INFO: Couldn't find grammar element for class test.dto.UserDto
What does this mean?
Copied from original issue: krasserm#57
From @Blue-Head on June 12, 2014 17:30
I kind of figure out a work-around, however, I wanted to post it to be taken into consideration ..
I followed the installation guide and things were okay and valid but I didn't create any resources(Jax-RS), just included the maven -repo and installed the plugin to my Grails project but when trying to start the app, I get the below exception which fails the whole initiation.
Exception sending context initialized event to listener instance of class org.grails.jaxrs.web.JaxrsListener
then I create a resource using the command line: grails create-resource
and cleaned the app and tried to run again, and the error just gone. so that's illogical because you are forcing the app to run the command (grails create-resource) at least for one time !
Note: I am using GGTS 3.5.1 with Grails 2.3.9
Thank You
Copied from original issue: krasserm#51
From @slackfarmer on February 27, 2015 21:8
I was curious how one might go about creating an IntegrationTestSpec that would compose a multipartFormData request? Does anyone have an example of how to build up a multipart form object and convert it to bytes using this existing jaxrs framework?
Currently send request will only accept bytes as input
@Override
HttpServletResponse sendRequest(String url, String method, byte[] content) {
defaultMixin.sendRequest(url, method, content)
}
HttpServletResponse sendRequest(String url, String method) {
defaultMixin.sendRequest(url, method, ''.bytes)
}
@Override
HttpServletResponse sendRequest(String url, String method, Map headers, byte[] content) {
defaultMixin.sendRequest(url, method, headers, content)
}
HttpServletResponse sendRequest(String url, String method, Map headers) {
defaultMixin.sendRequest(url, method, headers, ''.bytes)
}
def static uploadTestAsset(String srcAsset, String destPath) {
try {
def asset = new File("./src/test/resources/${srcAsset}" as String)
if (asset.exists()) {
if (!destPath.startsWith('/')) {
destPath = "/${destPath}" as String
}
String endpoint = "http://localhost/api/repo/upload${destPath}" as String
Client client = Client.create()
WebResource webResource = client.resource(endpoint)
def form = new FormDataMultiPart()
form.field('filename', asset.getName())
form.bodyPart(new FileDataBodyPart("fileUpload", asset, MediaType.APPLICATION_OCTET_STREAM_TYPE))
def result = webResource
.type(MULTIPART_FORM_DATA)
.accept(V1_JSON)
.put(String.class, form)
println "uploadTestAsset result: ${result}"
}
} catch (e) {
e.printStackTrace()
}
}
Copied from original issue: krasserm#61
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.