简体   繁体   English

找不到 MessageBodyWriter 类型的响应对象:java.util.LinkedHashMap 媒体类型:application/json

[英]Could not find MessageBodyWriter for response object of type: java.util.LinkedHashMap of media type: application/json

I have this REST service that returns JSON code :我有这个返回 JSON 代码的 REST 服务:

@GET
@Path("/mypath")
@Produces(MediaType.APPLICATION_JSON)
public Response getS() {
    Map<String, String> map = new LinkedHashMap<String, String>();

    map.put(key1, val1);
    map.put(key2, val2);

    return Response.ok(map, MediaType.APPLICATION_JSON).build();
}

This service is deployed in a Tomcat server.该服务部署在 Tomcat 服务器中。 I am using RESTeasy as framework.我使用 RESTeasy 作为框架。 When trying to access the service, I encounter this:尝试访问该服务时,我遇到了以下问题:

Could not find MessageBodyWriter for response object of type: java.util.LinkedHashMap of media type: application/json.找不到 MessageBodyWriter 类型的响应对象:java.util.LinkedHashMap 媒体类型:application/json。

I didn't understand what is the problem.我不明白有什么问题。

Thanks in advance提前致谢

How do you deploy your application?你如何部署你的应用程序? What application server do you use?你使用什么应用服务器? What version of RestEasy?什么版本的 RestEasy? What RestEasy configuration have you specified(in web.xml or Application class)?您指定了什么 RestEasy 配置(在 web.xml 或 Application 类中)? Resteasy relies on providers for serialization/deserialization of objects. Resteasy 依赖提供程序来进行对象的序列化/反序列化。 These providers need to contained in the classpath of your JAX-RS application.这些提供程序需要包含在 JAX-RS 应用程序的类路径中。 Depending on your build, application packaging and runtime environment these providers might be missing.根据您的构建、应用程序打包和运行时环境,这些提供程序可能会丢失。 Furthermore, discovery of providres can be configured, eg automatically discover all privoders in classpath, or only use those explicitly mentioned in conf.此外,可以配置providres的发现,例如自动发现classpath中的所有privoders,或者只使用conf中明确提到的那些。 Commonly used providers with application/json capabilities are resteasy-jackson-provider , resteasy-jettison-provider .具有 application/json 功能的常用提供程序是resteasy-jackson-providerresteasy-jettison-provider Verify that at least one of these is available in your classpath.验证在您的类路径中至少有一个可用。

暂无
暂无

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

相关问题 RestEasy:找不到类型的响应对象的MessageBodyWriter:java.util.Array媒体类型列表:application / json - RestEasy: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/json 找不到响应 object 类型的 MessageBodyWriter:java.util.ArrayList 媒体类型:text/html - 在 Resteasy 中 - Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: text/html - in Resteasy 无法为类型的响应对象找到MessageBodyWriter:com.sun.jersey.api.json.JSONWithPadding媒体类型:application / x-javascript - Could not find MessageBodyWriter for response object of type: com.sun.jersey.api.json.JSONWithPadding of media type: application/x-javascript org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:无法找到类型的响应对象的MessageBodyWriter:媒体类型:application / xml - org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: of media type: application/xml 如何使用java.util.LinkedHashMap $ EntryIterator类型访问对象值 - How to access the object value with java.util.LinkedHashMap$EntryIterator type NoMessageBodyWriterFoundFailure:找不到类型的响应对象的MessageBodyWriter - NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type 找不到媒体类型=应用程序/json,类型=类 java.util.ArrayList 的 MessageBodyWriter - MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList 无法读取JSON:无法构造`java.util.LinkedHashMap`的实例 - Could not read JSON: Cannot construct instance of `java.util.LinkedHashMap` 未找到 Media type=application/json 的 MessageBodyWriter - MessageBodyWriter not found for media type=application/json 找不到媒体类型= application / json的MessageBodyWriter - Getting MessageBodyWriter not found for media type=application/json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM