Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取“;对象反序列化错误”;添加spring安全性后的JSON流_Java_Json_Spring_Rest_Postman - Fatal编程技术网

Java 获取“;对象反序列化错误”;添加spring安全性后的JSON流

Java 获取“;对象反序列化错误”;添加spring安全性后的JSON流,java,json,spring,rest,postman,Java,Json,Spring,Rest,Postman,我正在使用Postman测试通过JSON的REST调用。获取、放置和发布都有效,直到我为登录添加了spring安全性。在那之后,我得到了工作,但帖子和帖子都没有 Post http://localhost:8000/json/equipments 标题 Accept application/json Content-type application/json Authorization Bearer eyJhbGciOiJIUzUxMi

我正在使用Postman测试通过JSON的REST调用。获取、放置和发布都有效,直到我为登录添加了spring安全性。在那之后,我得到了工作,但帖子和帖子都没有

Post    http://localhost:8000/json/equipments
标题

Accept              application/json
Content-type        application/json
Authorization       Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJwYXRyaWNrIiwiZXhwIjoxNDk5NzM3MzY1fQ.WWRampCM1C0QxA5IaTbqLWRHyeAJiLF8bxCBZBDbVbNjpANf1cDQIvUegEmP828kHJrkB6gQ0-zxauZe4cdlTQ
身体

邮递员返回

{
        "timestamp": 1498874735373,
        "status": 400,
        "error": "Bad Request",
        "exception": "org.springframework.http.converter.HttpMessageNotReadableException",
"message": "Could not read document: Object deserialize error\n at [Source: java.io.PushbackInputStream@5581e87c; line: 4, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Object deserialize error\n at [Source: java.io.PushbackInputStream@5581e87c; line: 4, column: 1]",
    "path": "/json/equipments"
}
mvn spring boot:run返回的日志

2017-06-30 20:12:54.552  WARN 42929 --- [nio-8000-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Object deserialize error
 at [Source: java.io.PushbackInputStream@166666cb; line: 4, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Object deserialize error
 at [Source: java.io.PushbackInputStream@166666cb; line: 4, column: 1]
2017-06-30 20:12:54.553  WARN 42929 --- [nio-8000-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Object deserialize error
 at [Source: java.io.PushbackInputStream@166666cb; line: 4, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Object deserialize error
 at [Source: java.io.PushbackInputStream@166666cb; line: 4, column: 1]

我在网上发现了许多类似的错误,但没有一个像这样。它们通常是缺少构造函数之类的问题。在保护应用程序之前,它工作得很好,我看不出数据有任何问题。有什么想法吗?我已经尝试了我能想到的一切。

您使用的是哪种安全机制?httpBasic还是formLogin?您是否将HTTP请求中的正确凭据传递给控制器?实际上两者都是。FormLogin用于web页面,httpBasic用于JSON。这是一个SpringRoo2.0应用程序,所以很多代码都是隐藏的。我成功登录了双方。因此,在我调用/jsonlogin并传递JWT令牌之后,JSON调用对GET有效,甚至puts和POST都经过身份验证,或者我认为它甚至不会尝试读取消息体。你觉得这样对吗?我不熟悉JSON、JWT、Spring Security和Spring Boot。我会首先选择正确的安全机制并使用它,但不是两者都使用。它既是一个网站,又为移动设备应用程序提供REST调用。我可以在网页上使用JWT吗?我认为那是不可能的。我会研究一下的,看来不行。JWT只是JSON。
2017-06-30 20:12:54.552  WARN 42929 --- [nio-8000-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Object deserialize error
 at [Source: java.io.PushbackInputStream@166666cb; line: 4, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Object deserialize error
 at [Source: java.io.PushbackInputStream@166666cb; line: 4, column: 1]
2017-06-30 20:12:54.553  WARN 42929 --- [nio-8000-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Object deserialize error
 at [Source: java.io.PushbackInputStream@166666cb; line: 4, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Object deserialize error
 at [Source: java.io.PushbackInputStream@166666cb; line: 4, column: 1]