【问题标题】:ClientHandlerException, Message Body Writer mime media type application/jsonClientHandlerException, Message Body Writer mime 媒体类型 application/json
【发布时间】:2014-12-15 14:32:00
【问题描述】:

我在我的代码中添加了一个新的 Web 服务。为此,我必须添加一个新的具体数据 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

【问题讨论】:

    标签: web-services jakarta-ee


    【解决方案1】:

    我所要做的就是在类定义中添加一个注解@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 答案,尽管它没有指出我的问题的完美解决方案,但它确实有提示。

    【讨论】:

    • @XmlRootElement 为我工作,但我不知道为什么:-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-24
    • 2014-03-27
    • 2015-12-13
    • 2014-03-20
    • 2012-08-16
    • 2018-01-26
    • 2018-04-20
    相关资源
    最近更新 更多