ClientHandlerException,Message Body Writer mime媒体类型application / json

时间:2014-12-15 06:30:33

标签: web-services java-ee

我在我的代码中添加了一个新的Web服务。为此我必须添加一个新的Concrete Data POJO集。

import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
import com.swipex.common.authenticator.IAuthenticable;

public class CServiceCenterOwnerDetails implements IServiceCenterOwnerDetails,
        IServiceCenterOwnerDetailsSetters, IAuthenticable, Serializable {
    private static final long serialVersionUID = 1L;

我得到的例外是

com.sun.jersey.api.client.clienthandlerexception: a message body writer for java type, class , and mime media type, application/json, was not found at com.sun.jersey.client.urlconnection.urlconnectionclienthandler.handle

1 个答案:

答案 0 :(得分:0)

我所要做的就是在类定义中添加注释@XmlRootElement,并且它有效。

import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
import com.swipex.common.authenticator.IAuthenticable;

@XmlRootElement
public class CServiceCenterOwnerDetails implements IServiceCenterOwnerDetails,
        IServiceCenterOwnerDetailsSetters, IAuthenticable, Serializable {
    private static final long serialVersionUID = 1L;

参考this回答,即使它没有指出我的问题的完美解决方案,它确实有一个提示。