Package org.springframework.http.converter

Examples of org.springframework.http.converter.HttpMessageNotReadableException


      }
      Document document = documentBuilder.parse(body);
      return new DOMSource(document);
    }
    catch (ParserConfigurationException ex) {
      throw new HttpMessageNotReadableException("Could not set feature: " + ex.getMessage(), ex);
    }
    catch (SAXException ex) {
      throw new HttpMessageNotReadableException("Could not parse document: " + ex.getMessage(), ex);
    }
  }
View Full Code Here


        reader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
      }
      return new SAXSource(reader, new InputSource(new ByteArrayInputStream(bytes)));
    }
    catch (SAXException ex) {
      throw new HttpMessageNotReadableException("Could not parse document: " + ex.getMessage(), ex);
    }
  }
View Full Code Here

      }
      XMLStreamReader streamReader = inputFactory.createXMLStreamReader(body);
      return new StAXSource(streamReader);
    }
    catch (XMLStreamException ex) {
      throw new HttpMessageNotReadableException("Could not parse document: " + ex.getMessage(), ex);
    }
  }
View Full Code Here

        JAXBElement<?> jaxbElement = unmarshaller.unmarshal(source, clazz);
        return jaxbElement.getValue();
      }
    }
    catch (UnmarshalException ex) {
      throw new HttpMessageNotReadableException("Could not unmarshal to [" + clazz + "]: " + ex.getMessage(), ex);

    }
    catch (JAXBException ex) {
      throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex);
    }
View Full Code Here

        throw new TypeMismatchException(result, clazz);
      }
      return result;
    }
    catch (UnmarshallingFailureException ex) {
      throw new HttpMessageNotReadableException("Could not read [" + clazz + "]", ex);
    }
  }
View Full Code Here

    Reader json = new InputStreamReader(inputMessage.getBody(), getCharset(inputMessage.getHeaders()));
    try {
      return this.gson.fromJson(json, token.getType());
    }
    catch (JsonParseException ex) {
      throw new HttpMessageNotReadableException("Could not read JSON: " + ex.getMessage(), ex);
    }
  }
View Full Code Here

        event = moveToNextElement(streamReader);
      }
      return result;
    }
    catch (UnmarshalException ex) {
      throw new HttpMessageNotReadableException("Could not unmarshal to [" + elementClass + "]: " + ex.getMessage(), ex);
    }
    catch (JAXBException ex) {
      throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex);
    }
    catch (XMLStreamException ex) {
View Full Code Here

    testException(ex);
  }

  @Test
  public void httpMessageNotReadable() {
    Exception ex = new HttpMessageNotReadableException("message");
    testException(ex);
  }
View Full Code Here

    }

    @Override
    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
        NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
      throw new HttpMessageNotReadableException("oops, can't read");
    }
View Full Code Here

    assertEquals("Invalid status code", 400, response.getStatus());
  }

  @Test
  public void handleHttpMessageNotReadable() {
    HttpMessageNotReadableException ex = new HttpMessageNotReadableException("foo");
    ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
    assertNotNull("No ModelAndView returned", mav);
    assertTrue("No Empty ModelAndView returned", mav.isEmpty());
    assertEquals("Invalid status code", 400, response.getStatus());
  }
View Full Code Here

TOP

Related Classes of org.springframework.http.converter.HttpMessageNotReadableException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.