JsonSlurper 执行失败 [英] JsonSlurper execution failure

查看:36
本文介绍了JsonSlurper 执行失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 JsonSlurper 来输入来自不同文件的变量.但它在第二次执行时失败了.有人可以帮我吗?

I am trying to use JsonSlurper to input variables from different files. But it is failing at second execution. Could someone help me?

它从步骤 Jenkins_File_Path = readFile ( "${Local_Path_App}" + "/Jenkinsfile" ) 失败

Main.groovy

import groovy.json.JsonSlurper

Global_Settings_Path = readFile ("${Main_Local_Path}" + "/Config/GlobalSettings_Java.json" )
def jsonSlurper = new JsonSlurper()
def GlobalVariables = jsonSlurper.parseText(Global_Settings_Path)

Jenkins_File_Path = readFile ( "${Local_Path_App}" + "/Jenkinsfile" )
def jsonSlurper1 = new JsonSlurper()
def json = jsonSlurper1.parseText(Jenkins_File_Path)

GlobalSettings_Java.json

{
    "LOB": {
        "SVN_Config_Path": "testpath",
        "Local_Path_LOB": "test",
    }
}

Jenkinsfile

{
    "BUILD_INFO": {
        "Build_Type" : "Maven",
    }
}

错误日志

java.io.NotSerializableException: groovy.json.internal.LazyMap在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)在 org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)在 org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)在 org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)在 org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)在 java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)在 java.util.HashMap.internalWriteEntries(HashMap.java:1785)在 java.util.HashMap.writeObject(HashMap.java:1362)在 sun.reflect.GeneratedMethodAccessor469.invoke(未知来源)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在 java.lang.reflect.Method.invoke(Method.java:498)在 org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在 org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)在 org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)在 org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)在 org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)在 java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)在 java.util.TreeMap.writeObject(TreeMap.java:2438)在 sun.reflect.GeneratedMethodAccessor475.invoke(未知来源)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在 java.lang.reflect.Method.invoke(Method.java:498)在 org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在 org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)在 org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)在 org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:132)在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:433)在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:412)在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:357)在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)在 org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)在 java.util.concurrent.FutureTask.run(FutureTask.java:266)在 hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)在 jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)在 java.util.concurrent.FutureTask.run(FutureTask.java:266)在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在 java.lang.Thread.run(Thread.java:745)引起:发生的异常:在外地当地人现场来电在 e 场在实地计划在领域线程中在对象 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@7abaf96e 中完成:失败

java.io.NotSerializableException: groovy.json.internal.LazyMap 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.HashMap.internalWriteEntries(HashMap.java:1785) at java.util.HashMap.writeObject(HashMap.java:1362) at sun.reflect.GeneratedMethodAccessor469.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.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.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.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.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.TreeMap.writeObject(TreeMap.java:2438) at sun.reflect.GeneratedMethodAccessor475.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:433) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:412) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:357) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63) 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) Caused by: an exception which occurred: in field locals in field caller in field e in field program in field threads in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@7abaf96e Finished: FAILURE

推荐答案

tl;dr:JsonSlurper 更改为 JsonSlurperClassic.

答案:

JsonSlurper 在表面下使用的 LazyMap 类经常是这个问题和许多其他问题的根源.旧版本的 JsonSlurper,在当前版本中作为 JsonSlurperClassic 找到,使用常规的、可序列化的 Java HashMap 用于这些目的,因此不容易解决同样的问题.

The LazyMap class used under the surface by JsonSlurper is frequently the source of this and many other problems. The older version of JsonSlurper, found in current releases as JsonSlurperClassic, uses a regular, serializable Java HashMap for those purposes, and hence is not prone to the same sorts of problems.

这篇关于JsonSlurper 执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆