Announcement Announcement Module
No announcement yet.
Capturing in Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Capturing in Spring

    Hi Every One,

    I am using Spring MVC to Build rest webservices.

    1. I am using spring provided json converter for Json to Java Object Conversion

    class="org.springframework.web.servlet.mvc.annotat ion.DefaultAnnotationHandlerMapping" />
    class="org.springframework.web.servlet.mvc.annotat ion.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
    <ref bean="jsonConverter" />


    <bean id="jsonConverter"
    class="org.springframework.http.converter.json.Map pingJacksonHttpMessageConverter">
    <property name="supportedMediaTypes" value="application/json" />

    2) My Controller would Look Like below.

    @RequestMapping(method = RequestMethod.POST, value = "/addAttendee", headers = "Accept=application/xml, application/json;")
    public @ResponseBody
    AddAttendeeVO addAttendee(@RequestBody AddAttendeeVO requestVO) {
    return new AddAttendeeVO();

    3) AddAttendeeVO Object

    Public class AddAttendeeVO {

    private String firstName;
    private String lastName;


    4) Now if i try to access this rest method with the following json

    "firstName": "test",
    "lastName" : false


    I am getting the below error. (Internal Service Exception 500).

    The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre> : Can not deserialize instance of java.lang.String out of VALUE_FALSE token
    at [Source: [email protected] 54ac42; line: 1, column: 19]

    Now my question is , whether i can catch this exception in Controller, if consumer sends some invalid json object / Structure and send Gracefull error message to the end user.

    Thanks and Regards,
    Pradeep Alabe