简体   繁体   English

未找到有关类的消息正文编写器:类java.util.HashMap

[英]No message body writer found for class : class java.util.HashMap

I am trying to consume a JAXRS endpoint. 我正在尝试使用JAXRS端点。 here is what I tried to make it work. 这是我试图使其起作用的方法。

Map<String, String> variables = new HashMap<String, String>();
variables.put("email", "sample@gmail.com");     
List<Object> providers = new ArrayList<Object>();
JSONProvider provider = new JSONProvider();
provider.setNamespaceMap(variables);
providers.add(provider);

WebClient plainAddClient = WebClient.create("http://hostname:portnumber/cxf/jaxrs/EmailService/subscriber/update", providers);
plainAddClient.accept("application/json").type("application/json").post(variables);

when I try to run the above snippet, I get the following exception: 当我尝试运行上述代码段时,出现以下异常:

org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(AbstractClient.java:486) - .No message body writer found for class : class java.util.HashMap.

I have no clue whats going wrong with my approach. 我不知道我的方法出了什么问题。 Thanks for any suggestion. 感谢您的任何建议。

Seems to me like you're attempting to send json to the server but actually sending the HashMap instead? 在我看来,您正在尝试将json发送到服务器,但实际上是在发送HashMap吗? Is your message body correctly converted to json before sending it? 发送之前,您的消息正文是否正确转换为json?

Maybe try to send plain json for testing 也许尝试发送普通的json进行测试

plainAddClient.accept("application/json")
 .type("application/json")
 .post({"email":"sample@gmail.com"})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引发WebApplicationException时出错:com.sun.jersey.api.MessageException:找不到Java类java.util.HashMap的消息正文编写器 - error while throwing WebApplicationException : com.sun.jersey.api.MessageException: A message body writer for Java class java.util.HashMap not found 未找到类型为java.util.HashMap的返回值的转换器 - No converter found for return value of type: class java.util.HashMap 找不到Java类的消息正文编写器 - A message body writer for Java class not found 严重:未找到 Java 类 java.util.ArrayList 和 MIME 媒体类型 application/json 的消息正文编写器 - SEVERE: A message body writer for Java class java.util.ArrayList and MIME media type application/json was not found 找不到Java类型类java.util.ArrayList和MIME媒体类型application / xml的消息正文编写器 - A message body writer for Java type, class java.util.ArrayList, and MIME media type, application/xml, was not found 找不到Java类java.util.ArrayList和MIME媒体类型application / json的消息正文编写器 - A message body writer for Java class java.util.ArrayList and MIME media type application/json was not found 未找到Java类java.util.ArrayList ...和MIME媒体类型text / xml的消息正文编写器 - A message body writer for Java class java.util.ArrayList…and MIME media type text/xml was not found 通过响应正文中的“findAll”搜索时出现异常“没有此类字段:class 的年龄:java.util.HashMap$Node” - Exception “No such field: age for class: java.util.HashMap$Node” when search via “findAll” in response body REST Java类java.util.LinkedList的消息正文编写器 - REST A message body writer for Java class java.util.LinkedList Java类java.util.ArrayList的消息体编写器 - A message body writer for Java class java.util.ArrayList
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM