Java 8 UnmarshalException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 UnmarshalException class.

This code example shows how to use the following methods:getMessage
		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);
6
CodeRank
This code example shows how to use the following methods:getMessage
					} catch (Exception e) {
						throw new JAXBException("Preprocessing exception", e);
					} 
											 
				} else { 
					log.error(ue.getMessage(), ue);
					log.error(".. and mark not supported"); 
					throw ue;
				} 
			} 
			 
 
		} catch (JAXBException e ) {
			log.error(e.getMessage(), e);
			throw e;
		} 
    	 
		return jaxbElement;
    	 
    }	 
5
CodeRank
This code example shows how to use the following methods:getMessage
                rootConfigElement = ((JAXBElement<T>) unmarshaledObj).getValue();
            } else { 
                throw new ConfigurationParserException("Failed to read config and no exception was thrown. Potential bug. Please report this."); 
            } 
        } catch (UnmarshalException mue) {
            throw new ConfigurationParserException("Your configuration may be malformed. Please review it and make sure it validates correctly. Reason: " 
                    + mue.getMessage(), mue);
        } catch (Exception ex) {
            throw new ConfigurationParserException("Failed to read the configuration. Reason: " 
                    + "" + ex.getMessage()
                    + " - pump cause for more details", ex);
        } 
 
        return rootConfigElement;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
                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);
5
CodeRank
This code example shows how to use the following methods:
 
    private XMLStreamReader createXmlStreamReader(Reader reader) throws JAXBException {
        try { 
            return Stax2JettisonFactory.createReader(reader, jsonConfig);
        } catch (XMLStreamException ex) {
            throw new UnmarshalException("Error creating JSON-based XMLStreamReader", ex);
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
                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:printStackTrace
        unmarshaller.setEventHandler(new CustomErrorValidationEventHandler(numberOfErrorsToIgnore));
        InputStream stream = ClassLoader.getSystemResourceAsStream(SINGLE_ERROR_XML);
        try { 
            Object o = unmarshaller.unmarshal(stream);
        } catch (UnmarshalException ex) {
            ex.printStackTrace();
            fail("Unable to ignore the xml validation errors");
            return; 
        } 
        test1passed = true;
        assertTrue("", true);
    } 
 
    public void testFailOnSecondError() throws Exception {
        unmarshaller.setEventHandler(new CustomErrorValidationEventHandler());
        InputStream stream = ClassLoader.getSystemResourceAsStream(DOUBLE_ERROR_XML);
        try { 
            Object o = unmarshaller.unmarshal(stream);
        } catch (UnmarshalException ex) {
            assertTrue("", true);
3
CodeRank
This code example shows how to use the following methods:
                return new JAXBElement(new QName(xmlRoot.getNamespaceURI(), xmlRoot.getLocalName()), xmlRoot.getObject().getClass(), xmlRoot.getObject());
            } else { 
                return returnValue; 
            } 
        } catch (Exception e) {
            throw new UnmarshalException(e);
        } 
    } 
 
    public JAXBElement unmarshal(Object obj, Class javaClass) throws JAXBException  {
        if (null == obj || null == javaClass) {
            throw new IllegalArgumentException();
        } 
 
        try { 
        	Root xmlRoot = (Root) xmlBinder.unmarshal((Node) obj, javaClass);
            return new JAXBElement(new QName(xmlRoot.getNamespaceURI(), xmlRoot.getLocalName()), javaClass, xmlRoot.getObject());
        } catch (Exception e) {
            throw new UnmarshalException(e);
        } 
3
CodeRank
See Code Examples for Java 8 UnmarshalException Methods: