dropwizard - 使用 Jersey 发出 Post 请求时服务器端的 Classcast 异常
问题描述
我正在调用使用 Dropwizard 开发的 Rest 服务,并且能够成功调用 Get 请求,但是将请求发布到同一服务(另一个端点离场)不起作用。它给出了 500 服务器错误,并且在日志中我看到以下异常:
Classcast exception: io.dropwizard.jetty.BiDiGzipHandler$WrappedInputStream cannot be cast to org.eclipse.jetty.server.request
这是我如何拨打电话的片段:
RequestPojo pojo = new RequestPojo (123, "test");
ObjectMapper mapper = new ObjectMapper();
String json=null;
try{
json = mapper.writeValueAsString(pojo);
}
catch(Exception e){
//loggers
}
Response response = target.request().accept(MediaType.Application_JSON).post(Entity.json(jsonString);
String id = response.readEntity(new GenericType<Map>(){}.get("generatedID"));
我几乎看不到任何帖子上的这个例外。有人可以帮我解决这个例外。谢谢你的帮助。
解决方案
推荐阅读
- reactjs - 更改视图缺少选定值时的反应选择
- maven - Maven中的BOM依赖与父依赖
- angular - Laravel - auth()->refresh() 在 JWT AuthController 中未定义?
- spring-boot - 如何使用 junit 5 spring boot 编写 pact-jvm 消费者驱动程序协议测试?
- pandas - 当一些列是可变的时更改列的顺序(熊猫)
- amazon-web-services - 从 AWS 上的转储中加载 Neo4J 数据库时出现问题
- swift - UIImage 填充图案颜色
- jquery - 如何根据jointjs中的文本调整矩形大小 - Rappid
- javascript - JS动画跳过文本中的空格
- rust - 有没有办法从一个本身需要 &mut self 的方法中传递 &mut self ?