Can not serialize instance of class out of START_ARRAY token\n

Razvan N

I am trying to use a web service with RESTful and JSON.

This is my method for POST:

@POST
public Response setCustomerInvoiceNotifications(SetCustomerInvoiceNotificationsRequestBO requestBO, @Context HttpHeaders hh) throws JSONException, Exception {
   init(config);

    Response response = null;
    ResultBO resultBO = (ResultBO) roalCache.callService("setCustomerInvoiceNotifications", requestBO, true);
    if (resultBO != null) {
        if (resultBO.getResult() != null) {

            SetCustomerInvoiceNotificationsResponseBO responseBO = (SetCustomerInvoiceNotificationsResponseBO)resultBO.getResult();
            ObjectFactory factory = new ObjectFactory();
            JSONObject jsonObject = new JSONObject(responseBO); 
            String result = "@Produces(\"application/json\") Output: \n\n Output: \n\n" + jsonObject;
            response = Response.status(200).cookie(cookie).entity(result).build();
        } else if (resultBO.getCause() != null) {
            JSONObject jsonObject = new JSONObject(resultBO.getCause());
            logger.debug("[{}]  jsonObject.toString = ",  jsonObject.toString() );
            String result = "@Produces(\"application/json\") Output: \n\n Output: \n\n" + jsonObject;  
            logger.debug("[{}]  jsonObject result = ",  result );
            response = Response.status(500).cookie(cookie).entity(result).build();  
        }
    }      
    return response;
}   

I am using a JSON with array:

[{
    "correlationId": "12345432",
    "customerId": "8508871",
    "notificationWhenIssued": {
        "destinations": {
            "channel": "email",
            "address": "[email protected]"
        }
    },
    "notificationBeforeDueDate": {
        "destinations": {
            "channel": "email",
            "address": "[email protected]"
        },
        "daysBeforeDueDate": "2"
    }
}]

After I post the JSON, I get this message error:

{"message":"Can not deserialize instance of com.upc.portal.business.SetCustomerInvoiceNotificationsRequestBO 
out of START_ARRAY token\n at 
[Source: weblogic.servlet.internal.ServletInputStreamImpl@17ac5e2; line: 1, column: 1]",
"stackTrace":"[org.codehaus.jackson.map.JsonMappingException.from(Unknown Source)...
Razvan N

I have found an answer to my problem:

I just added this to my web.xml file:

<init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>
     my.own.packages;
     org.codehaus.jackson.jaxrs</param-value>
</init-param>

I also included a jar - jackson-all-1.8.10

This worked out just fine with a correct format for the json input file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token - JAVA

From Java

Jackson error: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token

From Java

JsonMappingException: out of START_ARRAY token

From Dev

Json Mapping Exception can not deserialize instance out of START_ARRAY token

From Dev

Jackson: serialize only a given instance variable of a given class

From Dev

Cannot deserialize instance of object out of START_ARRAY token in Spring Webservice

From Dev

Can not deserialize instance of JsonGen out of START_ARRAY token : newbee

From Dev

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of org.springframework.data.domain.Sort out of START_ARRAY token

From Dev

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize out of START_ARRAY token

From Dev

Can not deserialize instance of Object out of START_ARRAY token

From Dev

Is it safe to serialize a class instance with a resource reference attribute?

From Dev

Ignore the "Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token" error

From Dev

How to serialize a Class with an Interface instance attribute? Got NotSerializableException

From Dev

Can not deserialize instance of java.util.HashMap out of START_ARRAY token

From Dev

Java REST API: Can not deserialize instance of Object out of START_ARRAY token

From Dev

com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token

From Dev

Convert JSON to Object throws JsonMappingException "Can not deserialize instance of class out of START_ARRAY token"

From Dev

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of Object out of START_ARRAY token

From Dev

Jackson: serialize only a given instance variable of a given class

From Dev

Xml serialize/deserialize an instance of a class to an 'ugly' xml format

From Dev

ObjectMapper fails to deserialize - cannot deserialize instance of .... out of START_ARRAY token

From Dev

out of START_ARRAY token in spring ajax call

From Dev

Can not deserialize instance of Object out of START_ARRAY token

From Dev

is it correct that a class can be an instance?

From Dev

JS can't serialize an array

From Dev

Java REST API: Can not deserialize instance of Object out of START_ARRAY token

From Dev

Can not deserialize instance of my package out of START_ARRAY token

From Dev

Can not deserialize instance of SaleListDTO out of START_ARRAY token

From Dev

make subclass serialize as an instance of the super class?

Related Related

  1. 1

    com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token - JAVA

  2. 2

    Jackson error: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token

  3. 3

    JsonMappingException: out of START_ARRAY token

  4. 4

    Json Mapping Exception can not deserialize instance out of START_ARRAY token

  5. 5

    Jackson: serialize only a given instance variable of a given class

  6. 6

    Cannot deserialize instance of object out of START_ARRAY token in Spring Webservice

  7. 7

    Can not deserialize instance of JsonGen out of START_ARRAY token : newbee

  8. 8

    com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of org.springframework.data.domain.Sort out of START_ARRAY token

  9. 9

    com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize out of START_ARRAY token

  10. 10

    Can not deserialize instance of Object out of START_ARRAY token

  11. 11

    Is it safe to serialize a class instance with a resource reference attribute?

  12. 12

    Ignore the "Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token" error

  13. 13

    How to serialize a Class with an Interface instance attribute? Got NotSerializableException

  14. 14

    Can not deserialize instance of java.util.HashMap out of START_ARRAY token

  15. 15

    Java REST API: Can not deserialize instance of Object out of START_ARRAY token

  16. 16

    com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token

  17. 17

    Convert JSON to Object throws JsonMappingException "Can not deserialize instance of class out of START_ARRAY token"

  18. 18

    com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of Object out of START_ARRAY token

  19. 19

    Jackson: serialize only a given instance variable of a given class

  20. 20

    Xml serialize/deserialize an instance of a class to an 'ugly' xml format

  21. 21

    ObjectMapper fails to deserialize - cannot deserialize instance of .... out of START_ARRAY token

  22. 22

    out of START_ARRAY token in spring ajax call

  23. 23

    Can not deserialize instance of Object out of START_ARRAY token

  24. 24

    is it correct that a class can be an instance?

  25. 25

    JS can't serialize an array

  26. 26

    Java REST API: Can not deserialize instance of Object out of START_ARRAY token

  27. 27

    Can not deserialize instance of my package out of START_ARRAY token

  28. 28

    Can not deserialize instance of SaleListDTO out of START_ARRAY token

  29. 29

    make subclass serialize as an instance of the super class?

HotTag

Archive