Spring Framework HttpMessageNotReadableException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework HttpMessageNotReadableException class.

This code example shows how to use the following methods:
				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);
		} 
	} 
 
	protected Source processSource(Source source) {
		if (source instanceof StreamSource) {
			StreamSource streamSource = (StreamSource) source;
			InputSource inputSource = new InputSource(streamSource.getInputStream());
			try { 
				XMLReader xmlReader = XMLReaderFactory.createXMLReader();
				String featureName = "http://xml.org/sax/features/external-general-entities";
5
CodeRank
This code example shows how to use the following methods:
				builder.mergeFrom(inputMessage.getBody(), this.extensionRegistry); 
			} 
			return builder.build(); 
		} 
		catch (Exception e) { 
			throw new HttpMessageNotReadableException("Could not read Protobuf message: " + e.getMessage(), e); 
		} 
	} 
 
	private Charset getCharset(HttpHeaders headers) { 
		if (headers == null || headers.getContentType() == null || headers.getContentType().getCharSet() == null) { 
			return DEFAULT_CHARSET; 
		} 
		return headers.getContentType().getCharSet(); 
	} 
 
	/** 
	 * Create a new {@code Message.Builder} instance for the given class. 
	 * <p>This method uses a ConcurrentHashMap for caching method lookups. 
	 */ 
5
CodeRank
This code example shows how to use the following methods:
		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);
		} 
	} 
 
	private Charset getCharset(HttpHeaders headers) {
		if (headers == null || headers.getContentType() == null || headers.getContentType().getCharSet() == null) {
			return DEFAULT_CHARSET;
		} 
		return headers.getContentType().getCharSet();
	} 
 
	@Override 
	protected void writeInternal(Object o, HttpOutputMessage outputMessage)
			throws IOException, HttpMessageNotWritableException {
 
5
CodeRank
This code example shows how to use the following methods:
		try { 
			JAXBElement<? extends I> jaxbElement = createUnmarshaller().unmarshal(source, internalClass);
			return convertToExternal(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);
		} 
	} 
 
	@Override 
	protected final void writeToResult(E accessToken, HttpHeaders headers, Result result) throws IOException {
		I convertedAccessToken = convertToInternal(accessToken);
		try { 
			createMarshaller().marshal(convertedAccessToken, result);
		} 
		catch (MarshalException ex) {
			throw new HttpMessageNotWritableException("Could not marshal [" + accessToken + "]: " + ex.getMessage(), ex);
5
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
                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);
        } 
    } 
 
    @Override 
    protected void writeToResult(Object o, HttpHeaders headers, Result result) throws IOException
    { 
        try 
        { 
            Class<?> clazz = ClassUtils.getUserClass(o);
4
CodeRank
This code example shows how to use the following methods:
      } else { 
        obj = mapper.readValue(nonFormattedString.getBytes(), Map.class);
      } 
      return mapper.writeValueAsString(obj);
    } catch(IOException e) {
      throw new HttpMessageNotReadableException(e.getMessage(), e);
    } 
  } 
 
} 
4
CodeRank