`

JSON转换net.sf.json.JSONException: There is a cycle

阅读更多

	at net.sf.json.util.CycleDetectionStrategy$StrictCycleDetectionStrategy.handleRepeatedReferenceAsObject(CycleDetectionStrategy.java:97)
	at net.sf.json.JSONObject._fromBean(JSONObject.java:859)
	at net.sf.json.JSONObject.fromObject(JSONObject.java:194)
	at net.sf.json.JSONObject._processValue(JSONObject.java:2793)
	at net.sf.json.JSONObject._setInternal(JSONObject.java:2817)
	at net.sf.json.JSONObject.setValue(JSONObject.java:1527)
	at net.sf.json.JSONObject._fromBean(JSONObject.java:946)
	at net.sf.json.JSONObject.fromObject(JSONObject.java:194)
	at net.sf.json.JSONArray._processValue(JSONArray.java:2562)
	at net.sf.json.JSONArray.processValue(JSONArray.java:2593)
	at net.sf.json.JSONArray.addValue(JSONArray.java:2580)
	at net.sf.json.JSONArray._fromCollection(JSONArray.java:1084)
	at net.sf.json.JSONArray.fromObject(JSONArray.java:147)
	at net.sf.json.JSONObject._processValue(JSONObject.java:2768)
	at net.sf.json.JSONObject._setInternal(JSONObject.java:2817)
	at net.sf.json.JSONObject.setValue(JSONObject.java:1527)
	at net.sf.json.JSONObject._fromBean(JSONObject.java:946)
	at net.sf.json.JSONObject.fromObject(JSONObject.java:194)
	at net.sf.json.JSONArray._processValue(JSONArray.java:2562)
	at net.sf.json.JSONArray.processValue(JSONArray.java:2593)
	at net.sf.json.JSONArray.addValue(JSONArray.java:2580)
	at net.sf.json.JSONArray._fromCollection(JSONArray.java:1084)
	at net.sf.json.JSONArray.fromObject(JSONArray.java:147)
	at net.sf.json.JSONArray.fromObject(JSONArray.java:129)
	at com.wangyu.web.action.MenuAction.execute(MenuAction.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:434)
	at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:273)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:235)
	at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:141)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:248)
	at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:49)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:124)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:170)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:170)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:104)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:84)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:208)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:88)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:130)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:137)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:130)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
	at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
	at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:477)
	at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:467)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Unknown Source)



异常原因是:

在解析bean时,出现死循环调用。

解决的办法,过滤去掉bean中引起死循环调用的属性:

    List nodes = proSrv.getProcesses();
        JSONObject jsonObj = new JSONObject();
        JsonConfig config = new JsonConfig();
        config.setJsonPropertyFilter(new PropertyFilter() {
            public boolean apply(Object source, String name, Object value) {
                if (name.equals("actions") || name.equals("globables")
                        || name.equals("transitions")) {
                    return true;
                } else {
                    return false;
                }
            }
        });
        jsonObj.put("list", JSONArray.fromObject(nodes, config));
分享到:
评论

相关推荐

    用于java对象与json对象间的相互转换(net.sf.json.JSONObject)

    `net.sf.json.JSONObject`是开源库Apache Commons的一个组件,提供了Java对象与JSON对象之间的转换功能。下面将详细阐述如何使用`JSONObject`进行JSON操作。 ### 1. 解析JSON字符串 当你从服务器获取或从文件读取...

    net.sf.json.JSONObject相关jar包.zip

    标题 "net.sf.json.JSONObject相关jar包.zip" 指的是一个包含了与net.sf.json.JSONObject类库相关的Java档案(JAR)文件的压缩包。这个类库是开源项目JSON.org的一部分,用于在Java应用程序中处理JSON(JavaScript ...

    json-lib出现There is a cycle in the hierarchy解决办法

    如果需要解析的数据间存在级联关系,而互相嵌套引用,在hibernate中极容易嵌套而抛出net.sf.json.JSONException: There is a cycle in the hierarchy异常。

    JSONException:com.alibaba.fastjson.JSONException: expect ‘:’ at 0, actual = 已解决

    在编程过程中,我们可能会遇到各种异常,其中"JSONException: expect ‘:’ at 0, actual =" 是一个典型的Fastjson库在解析JSON时抛出的异常。Fastjson是阿里巴巴提供的一款高性能的JSON解析和生成库,它广泛应用于...

    net.sf.json jar包

    7. **错误处理**:当解析JSON字符串或生成JSON对象时,如果遇到问题,`net.sf.json`会抛出异常,如`JSONException`,帮助开发者定位并解决问题。 总之,`net.sf.json`是一个强大的Java JSON处理库,它提供了一整套...

    json lib net.sf.json使用的所有jar包

    4. **自动映射和转换**:`net.sf.json.util.JSONUtils`类包含了一些静态方法,可以自动将JSON对象映射为JavaBean或Map,反之亦然,极大地简化了JSON与Java对象间的转换。 5. **JSON与XML互转**:`net.sf.json.XML`...

    Java下的json解析工具包:org.json.jar包

    - **XML与JSON的转换**: `XML.toString(JSONObject)`和`JSONObject.xmlToJSON(String xml)`分别用于将JSON对象转换为XML字符串,以及将XML字符串解析为JSON对象。 - **HTTP头与JSON的交互**: 库中的`HTTP`类可以...

    org.json.jar工具包下载(可用)

    6. **XML与JSON转换**:如果需要在XML和JSON之间转换,可以使用`XML.toString()`将JSON对象转换为XML字符串,或使用`XML.toJSONObject()`将XML字符串转换为`JSONObject`。 总之,`org.json.jar`工具包是Java开发中...

    Java json 解析json.jar

    用Java编程语言进行编码和解码JSON对象所需要的jar包。。

    json.jar与org.json.jar包

    2. `json-lib-2.4-jdk15.jar`:这是一个基于Net.sf.json的库,适用于多种Java环境,包括JDK1.5。它提供了与json.jar和org.json.jar类似的功能,同时也支持其他数据源,如DOM、SAX和Hibernate。 3. `json-path-0.8.1...

    json_jar_JSON_json.jar_

    3. **数据类型转换**:JSON.jar会处理JSON数据与Java数据类型的转换,比如将JSON字符串解析为Java的String、Number、Boolean、Array或Object等。 4. **JSON解析与生成**:库提供API来解析JSON文本,创建JSON对象...

    org.json.JSON.zip

    org.json库是由David Flanagan创建的,主要包含JSONObject、JSONArray、JSONString、JSONTokener、JSONException等类,用于解析和生成JSON格式的数据。JSON(JavaScript Object Notation)是一种轻量级的数据交换...

    json_jar.zip

    例如,`Gson().toJson(obj)`可以将一个Java对象转换成JSON字符串,而`Gson().fromJson(jsonStr, MyClass.class)`可以将JSON字符串反序列化为Java对象。 3. **Jackson库**:另一个流行的选择是Jackson库,它提供了`...

    json-src.zip org.json源码

    `org.json`是一个Java库,用于处理JSON数据,它提供了将JSON与Java对象相互转换的API。 在`org.json`源码包中,我们可以深入理解如何在Java中操作JSON对象。这个库包含了多个类和接口,如`JSONObject`、`JSONArray`...

    json.org.jar

    6. 错误处理:在解析或生成JSON过程中,如果遇到错误,`org.json`库会抛出相应的异常,如JSONException,帮助开发者定位问题。 在实际开发中,`json.org.jar`常被用于服务器端与客户端之间的数据交互,例如Web服务...

    org.json.jar.zip

    org.json.jar是一个轻量级的Java JSON处理库,它提供了一系列API,使得开发者能够方便地将JSON对象转换为Java对象,反之亦然。JSON(JavaScript Object Notation)是一种简洁且易于人阅读的数据交换格式,广泛应用于...

    org.json.JSONObject引用依赖包

    除了`JSONObject`,`org.json`包还提供了其他类,如`JSONArray`用于处理JSON数组,`JSONStringer`和`JSONWriter`用于构建复杂的JSON结构,以及`JSONException`用于捕获处理JSON时可能出现的异常。这些工具类使得...

    JAVA解析json文件(使用json.org.jar)

    在Java开发中,JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,常用于前后端数据传输。本文将详细讲解如何使用`json.org.jar`库在Android环境中解析JSON文件,帮助开发者理解这一过程。 首先,`...

Global site tag (gtag.js) - Google Analytics