When I add the Cometd plugin to Grails 1.2.1, grail's "jetty" debug environment will no longer start up.
I have been unable to debug this, not being familiar enough with the underlying components. (This is a big issue with Grails development in general. While it tries to hide everything from you, pretty soon you have to become an expert with Hibernate, Java 1.6, jetty, etc, in order to debug grails problems)
To reproduce, start a grails 1.2.1 project, and install the cometd-grails plugin. When you do a run-app, you'll see:
Running Grails application..
2010-03-20 18:32:28,879 [main] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoClassDefFoundError: org/mortbay/util/ajax/JSON$Source
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:74)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3961)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4456)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:515)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:708)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:286)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:129)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:225)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.Closure.call(Closure.java:279)
at groovy.lang.Closure.call(Closure.java:274)
at groovy.lang.Closure$call.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at groovy.lang.Closure$call.call(Unknown Source)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:155)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1095)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1051)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:706)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
at groovy.lang.Script.invokeMethod(Script.java:78)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1114)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1011)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:155)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1095)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1051)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:115)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:997)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:149)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:163)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:149)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
at groovy.lang.Closure.call(Closure.java:279)
at groovy.lang.Closure.call(Closure.java:292)
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:149)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure4_closure8_closure9.doCall(GantBinding.groovy:152)
at sun.reflect.GeneratedMethodAccessor77.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure4_closure8_closure9.doCall(GantBinding.groovy)
at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.Closure.call(Closure.java:279)
at groovy.lang.Closure.call(Closure.java:274)
at groovy.lang.Closure$call.call(Unknown Source)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:997)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:706)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1114)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1011)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:159)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure4_closure8.doCall(GantBinding.groovy:152)
at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure4_closure8.doCall(GantBinding.groovy)
at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.Closure.call(Closure.java:279)
at groovy.lang.Closure.call(Closure.java:274)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1095)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1051)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:706)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
at groovy.lang.Script.invokeMethod(Script.java:78)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1114)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1011)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:149)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:147)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:149)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
at groovy.lang.Closure.call(Closure.java:279)
at groovy.lang.Closure.call(Closure.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:149)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure4_closure8_closure9.doCall(GantBinding.groovy:152)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure4_closure8_closure9.doCall(GantBinding.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.Closure.call(Closure.java:279)
at groovy.lang.Closure.call(Closure.java:274)
at groovy.lang.Closure$call.call(Unknown Source)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:997)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:706)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1114)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1011)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:159)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure4_closure8.doCall(GantBinding.groovy:152)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure4_closure8.doCall(GantBinding.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
I just figured it out. I needed to add
jetty-util-6.1.14.jar
in my lib directory. Strictly speaking, I didn't figure it out; I was able to find a reference in a bug report that suggested this. The connection between this message
java.lang.NoClassDefFoundError: org/mortbay/util/ajax/JSON$Source
and figuring out that that means I need jetty-util is hard for me to determine, if I wasn't fortunate enough to find it after several hours of googling....
Related
I'm actually updating an old grails 2.4.2 project to grails 5.2.2. My IDE is IntelliJ Idea (but the problem exists, even if I start grails from the command line through run-app)
Using adoptOpenJDK 11.0.16.1+1
Every time I've changed e.g. a controller, the recompile process is started and ends in an stackOverflow Exception:
File /.../grails-app/controllers/xyz/SyParameterController.groovy changed, recompiling...
Exception in thread "Thread-11" java.lang.StackOverflowError
at java.base/java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:73)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
at grails.util.Environment.setCurrentReloadError(Environment.groovy:238)
at jdk.internal.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
I already enhanced the Java-Stack-Size in the build.gradle file.
Is this a known error or do I have an obvious mistake?
I believe this was a known problem that was fixed in 5.2.3: https://github.com/grails/grails-core/issues/12608
EDIT: if you can't upgrade to 5.2.3, you can add grails.util.Environment locally and override the offending method as such:
static void setCurrentReloadError(Throwable currentReloadError) {
Environment.#currentReloadError = currentReloadError
}
This would not be a recommended long-term solution, but may be easier than upgrading, just to confirm that's your issue.
Setup
Let's assume I have the following configuration on my Jenkins Shared Library:
vars/
utils.groovy
src/
com.my.corp.utils/
tools/
Utilities.groovy
helpers/
Workflow.groovy
Workflow.groovy
package com.my.corp.utils.helpers
// import org.jenkinsci.plugins.workflow.cps.CpsScript
trait Workflow
{
def workflow
}
Utitities.groovy
package com.my.corp.utils.tools
import com.my.corp.utils.helpers.Workflow
// import org.jenkinsci.plugins.workflow.cps.CpsScript
class Utilities implements Serializable, Workflow
{
def x = 5
def y = 10
def echo(Map args)
{
this.workflow.sh """echo 'args: ${args}'"""
this.workflow.sh """echo 'args.inspect(): ${args.inspect()}'"""
this.workflow.sh """echo 'this.steps: ${this.workflow}'"""
this.workflow.echo message: args.inspect()
this.workflow.sh """echo "${this.workflow.class.getName()}; args: ${args}\""""
}
}
utils.groovy
import com.my.corp.utils.tools.Utilities
def call(Map params)
{
this.echo "${this}"
params.put('workflow', this)
new Utilities(params).echo(params)
}
The Problem
When, in the main pipeline, I call utils x: 1, y: 2,
the following error appears:
org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed
Full Trace
Long Java stacktrace warning!
14:56:21 org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
14:56:21 file:/var/lib/jenkins/jobs/Sandbox-Pipeline/builds/74/libs/245eaa38d10b90e40a75ee9676c50aa097d56330cf312d54476ed05f2c731cfa/src/com/my/corp/utils/tools/Utilities.groovy: -1: Unsupported array expression for CPS transformation in this context # line -1, column -1.
14:56:21 file:/var/lib/jenkins/jobs/Sandbox-Pipeline/builds/74/libs/245eaa38d10b90e40a75ee9676c50aa097d56330cf312d54476ed05f2c731cfa/src/com/my/corp/utils/tools/Utilities.groovy: -1: Unsupported array expression for CPS transformation in this context # line -1, column -1.
14:56:21 2 errors
14:56:21
14:56:21 at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
14:56:21 at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1107)
14:56:21 at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:624)
14:56:21 at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602)
14:56:21 at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579)
14:56:21 at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:323)
14:56:21 at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:293)
14:56:21 at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:279)
14:56:21 at groovy.lang.GroovyClassLoader.recompile(GroovyClassLoader.java:786)
14:56:21 at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:743)
14:56:21 at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:812)
14:56:21 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:576)
14:56:21 at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$TimingLoader.loadClass(CpsGroovyShell.java:170)
14:56:21 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:576)
14:56:21 at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:702)
14:56:21 at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:812)
14:56:21 at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:800)
14:56:21 at org.jenkinsci.plugins.workflow.cps.global.UserDefinedGlobalVariable.getValue(UserDefinedGlobalVariable.java:52)
14:56:21 at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:115)
14:56:21 at jdk.internal.reflect.GeneratedMethodAccessor7858.invoke(Unknown Source)
14:56:21 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:56:21 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
14:56:21 at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
14:56:21 at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
14:56:21 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
14:56:21 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
14:56:21 at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:41)
14:56:21 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
14:56:21 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
14:56:21 at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
14:56:21 at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
14:56:21 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:158)
14:56:21 at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
14:56:21 at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
14:56:21 at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
14:56:21 at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
14:56:21 at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
14:56:21 at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
14:56:21 at WorkflowScript.run(WorkflowScript:18)
14:56:21 at ___cps.transform___(Native Method)
14:56:21 at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
14:56:21 at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
14:56:21 at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
14:56:21 at jdk.internal.reflect.GeneratedMethodAccessor741.invoke(Unknown Source)
14:56:21 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:56:21 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
14:56:21 at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
14:56:21 at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
14:56:21 at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
14:56:21 at jdk.internal.reflect.GeneratedMethodAccessor744.invoke(Unknown Source)
14:56:21 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:56:21 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
14:56:21 at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
14:56:21 at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
14:56:21 at com.cloudbees.groovy.cps.Next.step(Next.java:83)
14:56:21 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
14:56:21 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
14:56:21 at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
14:56:21 at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
14:56:21 at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
14:56:21 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
14:56:21 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
14:56:21 at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
14:56:21 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
14:56:21 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
14:56:21 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
14:56:21 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
14:56:21 at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
14:56:21 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
14:56:21 at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
14:56:21 at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
14:56:21 at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
14:56:21 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
14:56:21 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
14:56:21 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
14:56:21 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
14:56:21 at java.base/java.lang.Thread.run(Thread.java:829)
However
However, if I change the Workflow to be an abstract class instead of trait, and use extends Workflow implements Serializible instead of implements Workflow, Serializible in the Utilities definition, everything works fine!
Furthermore, when I run the code above (with traits) in Groovy online executor, it works well too.
I am facing a weird issue when using curl in jenkins file. The api call is simple, just have to pass an authorization token to the api like below:
sh(script: "curl -u ${key}: https://mySonarQube/api/qualitygates/project_status?projectKey=ProjectName", returnStdout: true)
This throws an error like below:
an exception which occurred:
in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv#3fc99581
in field com.cloudbees.groovy.cps.impl.CallEnv.caller
in object com.cloudbees.groovy.cps.impl.FunctionCallEnv#6ba4ed98
in field com.cloudbees.groovy.cps.Continuable.e
in object org.jenkinsci.plugins.workflow.cps.SandboxContinuable#7caf7588
in field org.jenkinsci.plugins.workflow.cps.CpsThread.program
in object org.jenkinsci.plugins.workflow.cps.CpsThread#6a1f4c92
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup#12b444a
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup#12b444a
Caused: java.io.NotSerializableException: groovy.json.internal.LazyMap
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
at java.util.HashMap.writeObject(HashMap.java:1363)
at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.concurrent.ConcurrentSkipListMap.writeObject(ConcurrentSkipListMap.java:1437)
at sun.reflect.GeneratedMethodAccessor474.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.lambda$writeObject$0(RiverWriter.java:144)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:237)
at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:557)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:534)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:517)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:441)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
It seems it fails at this point Caused: java.io.NotSerializableException: groovy.json.internal.LazyMap but I dont know what happens behind the scene.
Its weird because when calling another api it works just fine. And if i open this api in browser I see json content in there which is just a regular json content.
Does anybody know what might be the issue ?
When I have the following in Groovy:
blub = Paths.get(pwd() + "/my/path")
echo blub.toString()
It prints
/jenkins/my/path
just fine.
But immediately after, I get the following exception:
java.io.NotSerializableException: sun.nio.fs.UnixPath
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:333)
at java.util.HashMap.writeObject(HashMap.java:1362)
at sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at com.cloudbees.groovy.cps.SerializableScript.writeObject(SerializableScript.java:26)
at sun.reflect.GeneratedMethodAccessor235.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.HashMap.internalWriteEntries(HashMap.java:1785)
at java.util.HashMap.writeObject(HashMap.java:1362)
at sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:132)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:452)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:427)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:415)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:360)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Can someone make sense, why it works but still fails?
You have to wrap your Path operation in method marked NonCPS:
#com.cloudbees.groovy.cps.NonCPS
def test(String value) {
// All Path operations here
Paths.get(value)
Read gory details here: https://github.com/jenkinsci/workflow-cps-plugin/#technical-design
I have a service that uses grails mail plugin
#Transactional
#Slf4j
class ExpireAlertService {
def mailService
...
...
void sendExpiryMails() {
def list = SomeDomain.list()
list.each {
log.debug('Sending Mail {}', it.id)
mailService.sendMail {
to 'to#somedomain.com'
from 'sender#mydomain.com'
subject "Expiry Alert !!!"
html view: "/email/expiry", model: [
id : id,
...
]
}
}
}
}
the email template is in grails-app/view/email/expiry.gsp. When this service is injected into a controller and called from some action, it works as expected and mail is sent. But when the same service is injected in Bootstrap.groovy or a scheduled job, I get this exception when it runs
java.lang.NullPointerException: null
at java.net.URI$Parser.parse(URI.java:3042) ~[na:1.8.0_92]
at java.net.URI.<init>(URI.java:588) ~[na:1.8.0_92]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_92]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_92]
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1075) ~[springloaded-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60) [groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235) [groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247) [groovy-2.4.5.jar:2.4.5]
at grails.plugins.mail.MailMessageContentRenderer$PageRenderRequestCreator.createInstance(MailMessageContentRenderer.groovy:198) ~[mail-2.0.0.RC4.jar:na]
at grails.plugins.mail.MailMessageContentRenderer$PageRenderRequestCreator$createInstance.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:141) [groovy-2.4.5.jar:2.4.5]
at grails.plugins.mail.MailMessageContentRenderer$RenderEnvironment.init(MailMessageContentRenderer.groovy:147) ~[mail-2.0.0.RC4.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) ~[springloaded-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71) ~[groovy-2.4.5.jar:2.4.5]
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 grails.plugins.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:178) ~[mail-2.0.0.RC4.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) ~[springloaded-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:91) ~[groovy-2.4.5.jar:2.4.5]
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:149) [groovy-2.4.5.jar:2.4.5]
at grails.plugins.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:63) ~[mail-2.0.0.RC4.jar:na]
at grails.plugins.mail.MailMessageContentRenderer$render.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 grails.plugins.mail.MailMessageBuilder.doRender(MailMessageBuilder.groovy:277) ~[mail-2.0.0.RC4.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) ~[springloaded-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) [groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) [groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) [groovy-2.4.5.jar:2.4.5]
at grails.plugins.mail.MailMessageBuilder.html(MailMessageBuilder.groovy:295) ~[mail-2.0.0.RC4.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) ~[springloaded-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.5.jar:2.4.5]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384) ~[groovy-2.4.5.jar:2.4.5]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) [groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) [groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) [groovy-2.4.5.jar:2.4.5]
at ExpireAlertService$__tt__sendExpiryMails_closure4$_closure7.doCall(ExpireAlertService.groovy:45) ~[main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
The exception originates at the html view:"/email/expiry" line. Is there anything that I need to do to resolve gsp views from non controller use cases ?
I am using grails 3.1.1 and mail plugin org.grails.plugins:mail:2.0.0.RC4
Any help is greatly appreciated.
This error happens when your serverUrl is not set. In my Bootstrap.groovy, I use this:
def grailsApplication // injected
...
LinkGenerator grailsLinkGenerator = grailsApplication.mainContext.getBean("grailsLinkGenerator")
grailsLinkGenerator.configuredServerBaseURL ?: grailsApplication.config.grails.serverUrl
This propagates the serverUrl configured on a per-environment basis without having to set a global one.