简体   繁体   English

JsonMappingException:找不到类型[simple type,class com.fasterxml.jackson.databind.node.ObjectNode]的合适构造函数

[英]JsonMappingException: No suitable constructor found for type [simple type, class com.fasterxml.jackson.databind.node.ObjectNode]

I have read JSONMappingException for External Object , JSONMappingException for Class but can't found solution for ObjectNode class. 我已经读过外部对象的 JSONMappingException,类的JSONMappingException,但找不到ObjectNode类的解决方案。

By Reading JSONMappingException for External Object I understand that you have to register Object in mapper but I have not created any ObjectMapper class as I am calling web service 通过读取外部对象的JSONMappingException我明白你必须在mapper中注册Object但是我没有创建任何ObjectMapper类,因为我正在调用Web服务

mapper.registerModule(new GeoModule());

I am trying to call web service of My POJO ( ReportQueryData.java ) which contain ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode) instance variable. 我试图调用包含ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)实例变量的My POJO( ReportQueryData.java )的Web服务。

ReportQueryData.java ReportQueryData.java

import com.fasterxml.jackson.databind.node.ObjectNode;

public class ReportQueryData {
    private ObjectNode parentsData;

    public ObjectNode getParentsData() {
        return parentsData;
    }

    public void setParentsData(ObjectNode parentsData) {
        this.parentsData = parentsData;
    }
}

Now I am calling web service containing ReportQueryData in request and I am facing below exception 现在我在请求中调用包含ReportQueryData的Web服务,我面临下面的异常

org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple type, class com.fasterxml.jackson.databind.node.ObjectNode]: can not instantiate from JSON object (need to add/enable type information?)
[INFO] [talledLocalContainer]  at [Source: org.apache.catalina.connector.CoyoteInputStream@3da45801; line: 1, column: 155] (through reference chain: com.atlassian.qtm.model.ReportQueryData["parentsData"])
[INFO] [talledLocalContainer]   at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
[INFO] [talledLocalContainer]   at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObjectUsingNonDefault(BeanDeserializer.java:740)
[INFO] [talledLocalContainer]   at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:683)

You have to write default constructor for this class also like this 您必须为此类编写默认构造函数,如下所示

public ReportQueryData (){

}

Edit: : try to wrap that class in your and use your class. 编辑::尝试将该课程包装在您的课程中并使用您的课程。

 class A{

    A(String s){

    }
}

class B extends A{

    B(){
        super("str");
    }
}

暂无
暂无

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

相关问题 com.fasterxml.jackson.databind.node.ObjectNode无法转换为org.codehaus.jackson.node.ObjectNode - com.fasterxml.jackson.databind.node.ObjectNode cannot be converted to org.codehaus.jackson.node.ObjectNode com.fasterxml.jackson.databind.JsonMappingException:无法构造实例:poja class 找不到合适的构造函数 - com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of : poja class no suitable constructor found com.fasterxml.jackson.databind.JsonMappingException:无法实例化类型[简单类型,类car.Part]的值 - com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class car.Part] Jersey Rest - JsonMappingException:找不到类型[simple type,class]的合适构造函数 - Jersey Rest - JsonMappingException: No suitable constructor found for type [simple type, class ] 错误:com.fasterxml.jackson.databind.JsonMappingException:未找到序列化程序 - error: com.fasterxml.jackson.databind.JsonMappingException: No serializer found com.fasterxml.jackson.databind.JsonMappingException 无法构造类的实例 - com.fasterxml.jackson.databind.JsonMappingException not able to construct instance of class com.fasterxml.jackson.databind.JsonMappingException 在成员类型和访问器方法之间存在不一致时通过引用链 - com.fasterxml.jackson.databind.JsonMappingException through reference chain when there is inconsistency between member type and accessor methods JsonMappingException:找不到类型[simple type,class car.Car $ Parts]的合适构造函数 - JsonMappingException: No suitable constructor found for type [simple type, class car.Car$Parts] JsonMappingException:找不到适合类型 [简单类型,类] 的构造函数:无法从 JSON 对象实例化 - JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object “com.fasterxml.jackson.databind.JsonMappingException:预期类型为浮点数、整数或字符串。” 使用 ObjectMapper 转换 java.time.Instant - "com.fasterxml.jackson.databind.JsonMappingException: Expected type float, integer, or string." converting the java.time.Instant with ObjectMapper
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM