网:: ERR-无效-CHUNKED编码

时间:2015-04-06 07:24:27

标签: java html web

我遇到一个异常错误,只有在我的网络应用程序的任何页面上请求URL时才会在某些PC上发生。 错误是:

  

净:: ERR-INVALID-CHUNKED编码

错误并不总是发生,但我可以说3个请求中的2个必然会出错。 该应用程序是Spring MVC jar,它部署在Web服务器上。

请帮忙吗?

1 个答案:

答案 0 :(得分:0)

我的Java / Spring / Hibernate Web应用程序中有类似的问题。在Chrome浏览器和Postman客户端中可以看到它,但在Firefox中却没有(它似乎更容忍违反http规范)。

Rest API控制器必须响应一个JSON,其中包含来自数据库的实体列表。看来实体之间存在循环依赖。序列化此实体时,它导致StackOverflowError,进而在响应传输期间意外关闭了连接。这是从服务器端看的样子:

10:42:08.665 [http-nio-8080-exec-3] ERROR com.myproject.rest.common.GlobalErrorHandler - Error while performing REST call org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Infinite recursion (StackOverflowError); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: 
com.myproject.domain2.Device["compoundDevice"]- 
>com.myproject.domain2.Device["compoundDevice"]->com.myproject.domain2.Device["compoundDevice"]->com.myproject.domain2.Device["compoundDevice"]->com.myproject.domain2.Device["compoundDevice"]->com.myproject.domain2.Device["compoundDevice"]->com.myproject.domain2.Device["compoundDevice"]->com.myproject.domain2.Device["compoundDevice"]->com.myproject.domain2.Device["compoundDevice"]-
....
Caused by: java.lang.StackOverflowError
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
at java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[?:?]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) ~[?:?]
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2415) ~[catalina.jar:9.0.20]
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:863) ~[catalina.jar:9.0.20]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) ~[catalina.jar:9.0.20]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1186) ~[catalina.jar:9.0.20]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:773) ~[jackson-databind-2.11.1.jar:2.11.1]
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178) ~[jackson-databind-2.11.1.jar:2.11.1]
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728) ~[jackson-databind-2.11.1.jar:2.11.1]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755) ~[jackson-databind-2.11.1.jar:2.11.1]
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178) ~[jackson-databind-2.11.1.jar:2.11.1]
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728) ~[jackson-databind-2.11.1.jar:2.11.1]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755) ~[jackson-databind-2.11.1.jar:2.11.1]
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178) ~[jackson-databind-2.11.1.jar:2.11.1] 
...