groovy.lang.MissingPropertyException:无此类属性:类的委托:java.lang.String

时间:2019-12-27 08:28:54

标签: groovy plugins artifactory

正在尝试修改默认的Artifactory清理插件https://github.com/jfrog/artifactory-user-plugins/tree/master/cleanup/artifactCleanup

此插件的数据源将采用以下json格式,这与用户托管的当前插件略有不同。

我成功处理了json数据,并能够获取uniquteTimeIntervals和RepoList,但是插件代码在artifactCleanUp方法调用中失败

{
    "totalRepo": 597,
    "uniqueIntervals": [
        6,
        1,
        3,
        2
    ],
    "repos": [
        {
            "repoName": "repo1",
            "repoOwner": "owner",
            "timeInterval": 6
        },
        {
            "repoName": "repo2",
            "repoOwner": "owner2",
            "timeInterval": 6
        },
jobs {
    cleanupPluginReload(cron: "0 */1 * * * ?"){ //just for testing purposes
        def configFile = new File(ctx.artifactoryHome.haAwareEtcDir, CONFIG_FILE_PATH)
        def repoList = jsonSlurper.parse(configFile.toURL())
        def timeIntervalList = []
        def paceTimeMS = 500 as int
        def dryRun = true as Boolean
        def disablePropertiesSupport = false as Boolean
        timeIntervalList = repoList.uniqueIntervals
        for (interval in timeIntervalList){
            def timeInterval = interval as int
            def repo_list = [] as String []
            for (repo in repoList.repos){
                if(timeInterval == repo.timeInterval as int)
                    String rep =  "\""+repo.repoName+"\""
                    repo_list += rep
            }
            artifactCleanup( DEFAULT_TIME_UNIT, timeInterval, repo_list, log, paceTimeMS, dryRun, disablePropertiesSupport )
         }
    }
}

目前不清楚导致错误的原因。该错误发生在当artifactCleanup方法被调用


2019-12-27 02:30:00,039 [art-exec-4] [ERROR] (o.q.c.JobRunShell   :211) - Job artifactory.PluginCommand#08d4f3aa-e98d-4939-9f6e-3eb14a4232fb threw an unhandled Exception: 
groovy.lang.MissingPropertyException: No such property: delegate for class: java.lang.String
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:499)
        at Script1$_run_closure1.doCall(Script1.groovy:1)
        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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:84)
        at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:951)
        at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1279)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1227)
        at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1125)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
        at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
        at groovy.lang.Script.invokeMethod(Script.java:80)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:414)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:340)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
        at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:398)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:340)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
        at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:398)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:338)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
        at artifactCleanup$_run_closure1$_closure5$_closure6.doCall(artifactCleanup.groovy:76)
        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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.Closure.call(Closure.java:420)
        at groovy.lang.Closure.call(Closure.java:436)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2125)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2110)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2151)
        at org.codehaus.groovy.runtime.dgm$163.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:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
        at artifactCleanup$_run_closure1$_closure5.doCall(artifactCleanup.groovy:65)
        at artifactCleanup$_run_closure1$_closure5.doCall(artifactCleanup.groovy)
        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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.Closure.call(Closure.java:420)
        at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:54)
        at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:124)
        at com.sun.proxy.$Proxy389.execute(Unknown Source)
        at org.artifactory.schedule.quartz.PluginCommand.onExecute(PluginCommand.java:55)
        at org.artifactory.schedule.quartz.QuartzCommand.execute(QuartzCommand.java:48)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        at org.artifactory.concurrent.ArtifactoryRunnable.run(ArtifactoryRunnable.java:50)
        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)
2019-12-27 02:30:00,039 [art-exec-4] [ERROR] (o.q.c.ErrorLogger   :2425) - Job (artifactory.PluginCommand#08d4f3aa-e98d-4939-9f6e-3eb14a4232fb threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception.
        at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
        at org.artifactory.concurrent.ArtifactoryRunnable.run(ArtifactoryRunnable.java:50)
        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)
Caused by: groovy.lang.MissingPropertyException: No such property: delegate for class: java.lang.String
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:499)
        at Script1$_run_closure1.doCall(Script1.groovy:1)
        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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:84)
        at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:951)
        at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1279)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1227)
        at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1125)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
        at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
        at groovy.lang.Script.invokeMethod(Script.java:80)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:414)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:340)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
        at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:398)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:340)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
        at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:398)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:338)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
        at artifactCleanup$_run_closure1$_closure5$_closure6.doCall(artifactCleanup.groovy:76)
        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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.Closure.call(Closure.java:420)
        at groovy.lang.Closure.call(Closure.java:436)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2125)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2110)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2151)
        at org.codehaus.groovy.runtime.dgm$163.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:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
        at artifactCleanup$_run_closure1$_closure5.doCall(artifactCleanup.groovy:65)
        at artifactCleanup$_run_closure1$_closure5.doCall(artifactCleanup.groovy)
        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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
        at groovy.lang.Closure.call(Closure.java:420)
        at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:54)
        at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:124)
        at com.sun.proxy.$Proxy389.execute(Unknown Source)
        at org.artifactory.schedule.quartz.PluginCommand.onExecute(PluginCommand.java:55)
        at org.artifactory.schedule.quartz.QuartzCommand.execute(QuartzCommand.java:48)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        ... 4 common frames omitted

有人可以解释引起Nosuchpropertyexception的原因:

0 个答案:

没有答案