Example usage for javax.xml.bind JAXBException JAXBException

List of usage examples for javax.xml.bind JAXBException JAXBException

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException JAXBException.

Prototype

public JAXBException(Throwable exception) 

Source Link

Document

Construct a JAXBException with a linkedException.

Usage

From source file:org.geosamples.samples.Samples.java

/**
 *
 * @see//from   w ww. j  av  a  2s .  com
 * <a href="http://www.iedadata.org/services/sesar_api#SESARRESTWebServiceAPIDocumentation-1.Sampleregistrationwebservice">SESAR
 * REST web services</a>
 * @param username
 * @param password
 * @param samples
 * @param serviceURL
 * @return
 * @throws JAXBException
 * @throws NoSuchAlgorithmException
 * @throws KeyStoreException
 * @throws KeyManagementException
 * @throws IOException
 */
private static XMLDocumentInterface registerSampleMetaDataWithSesar(String username, String password,
        XMLDocumentInterface samples, String serverURL)
        throws JAXBException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {

    boolean areValid = validateSamplesForUpload((Samples) samples, false);
    if (areValid) {
        return uploadSampleMetaDataWithSesar(username, password, samples,
                serverURL + GEOSAMPLES_SAMPLE_UPLOAD_WEBSERVICE_NAME);
    } else {
        throw new JAXBException("Invalid content in sample XML.");
    }
}

From source file:org.geosamples.samples.Samples.java

private static XMLDocumentInterface updateSampleMetaDataWithSesar(String username, String password,
        XMLDocumentInterface samples, String serverURL)
        throws JAXBException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {

    boolean areValid = validateSamplesForUpload((Samples) samples, true);
    if (areValid) {
        return uploadSampleMetaDataWithSesar(username, password, samples,
                serverURL + GEOSAMPLES_SAMPLE_UPDATE_IGSN_WEBSERVICE_NAME);
    } else {//  w  w  w.  jav  a 2  s .c o m
        throw new JAXBException("Invalid content in sample XML.");
    }
}

From source file:org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockFactoryImpl.java

public Block createFrom(OMElement omElement, Object context, QName qName)
        throws XMLStreamException, WebServiceException {
    // The context for a JAXBFactory must be non-null and should be a JAXBBlockContext.
    if (context == null) {
        // JAXWS spec 4.3.4 conformance requires a WebServiceException whose cause is JAXBException
        throw ExceptionFactory.makeWebServiceException(
                new JAXBException(Messages.getMessage("JAXBBlockFactoryErr1", "null")));
    } else if (context instanceof JAXBBlockContext) {
        ;//from www  .  java  2s .c  o m
    } else {
        // JAXWS spec 4.3.4 conformance requires a WebServiceException whose cause is JAXBException
        throw ExceptionFactory.makeWebServiceException(
                new JAXBException(Messages.getMessage("JAXBBlockFactoryErr1", context.getClass().getName())));
    }
    if (qName == null) {
        qName = omElement.getQName();
    }

    if (omElement instanceof OMSourcedElement) {

        if (((OMSourcedElement) omElement).getDataSource() instanceof JAXBDataSource) {
            JAXBDataSource ds = (JAXBDataSource) ((OMSourcedElement) omElement).getDataSource();
            JAXBDSContext dsContext = ds.getContext();
            try {
                if (dsContext.getJAXBContext() == ((JAXBBlockContext) context).getJAXBContext()) {
                    // Shortcut, use existing JAXB object
                    Object jaxb = ds.getObject();
                    return new JAXBBlockImpl(jaxb, (JAXBBlockContext) context, qName, this);
                }
            } catch (JAXBException e) {
                if (log.isDebugEnabled()) {
                    log.debug("Falling back to using normal unmarshalling approach. " + e.getMessage());
                }
            }
        } else if (((OMSourcedElement) omElement).getDataSource() instanceof JAXBBlockImpl) {
            JAXBBlockImpl block = (JAXBBlockImpl) ((OMSourcedElement) omElement).getDataSource();
            JAXBBlockContext blockContext = (JAXBBlockContext) block.getBusinessContext();
            try {
                if (blockContext.getJAXBContext() == ((JAXBBlockContext) context).getJAXBContext()) {
                    // Shortcut, use existing JAXB object
                    Object jaxb = block.getObject();
                    return new JAXBBlockImpl(jaxb, (JAXBBlockContext) context, qName, this);
                }
            } catch (JAXBException e) {
                if (log.isDebugEnabled()) {
                    log.debug("Falling back to using normal unmarshalling approach. " + e.getMessage());
                }
            }
        }
    }

    return new JAXBBlockImpl(omElement, (JAXBBlockContext) context, qName, this);
}

From source file:org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockFactoryImpl.java

public Block createFrom(Object businessObject, Object context, QName qName) throws WebServiceException {

    // The context must be non-null and should be a JAXBBlockContext.
    // For legacy reasons, a JAXBContext is also supported (and wrapped into a JAXBBlockContext)
    if (context == null) {
        // JAXWS spec 4.3.4 conformance requires a WebServiceException whose cause is JAXBException
        throw ExceptionFactory.makeWebServiceException(
                new JAXBException(Messages.getMessage("JAXBBlockFactoryErr1", "null")));
    } else if (context instanceof JAXBBlockContext) {
        ;//from   w  w w .  j  ava2s  .c o m
    } else {
        // JAXWS spec 4.3.4 conformance requires a WebServiceException whose cause is JAXBException
        throw ExceptionFactory.makeWebServiceException(
                new JAXBException(Messages.getMessage("JAXBBlockFactoryErr1", context.getClass().getName())));
    }

    // The business object must be either a JAXBElement or a block with an @XmlRootElement qname.  
    // (Checking this is expensive, so it is assumed)
    // The input QName must be set otherwise we have to look it up, which kills performance.
    if (qName == null) {
        qName = XMLRootElementUtil.getXmlRootElementQNameFromObject(businessObject);
    }

    try {
        return new JAXBBlockImpl(businessObject, (JAXBBlockContext) context, qName, this);
    } catch (JAXBException e) {
        throw ExceptionFactory.makeWebServiceException(e);
    }
}

From source file:org.betaconceptframework.astroboa.model.jaxb.AstroboaMarshaller.java

@Override
public void marshal(Object arg0, Writer arg1) throws JAXBException {
    if (outputTypeIsJSON()) {

        XMLStreamWriter jsonXmlStreamWriter = null;
        try {//from w  w w  .j  a v  a2 s .c  om

            jsonXmlStreamWriter = CmsEntitySerialization.Context.createJsonXmlStreamWriter(arg1, true,
                    BooleanUtils.isTrue((Boolean) marshaller.getProperty(Marshaller.JAXB_FORMATTED_OUTPUT)));

            marshal(arg0, jsonXmlStreamWriter);
        } catch (Exception e) {
            try {
                if (jsonXmlStreamWriter != null) {
                    jsonXmlStreamWriter.flush();
                    logger.error("JSON Export so far {}", arg1);
                }
            } catch (Exception e1) {
                //Ignore it
            }
            throw new JAXBException(e);
        }
    } else {
        marshaller.marshal(arg0, arg1);
    }

}

From source file:org.cauldron.tests.util.DigesterContext.java

public Marshaller createMarshaller() throws JAXBException {
    throw new JAXBException("Marshalling not supported by " + getClass());
}

From source file:org.cauldron.tests.util.DigesterContext.java

public Validator createValidator() throws JAXBException {
    throw new JAXBException("Validation not supported by " + getClass());
}

From source file:org.cauldron.tests.util.DigesterContext.java

protected Object unmarshal(XMLReader reader, InputSource input) throws JAXBException {
    reader.setContentHandler(digester);/* ww w. ja  v  a  2 s  . co  m*/

    try {
        reader.parse(input);
        return digester.getRoot();
    } catch (Exception e) {
        throw new JAXBException(e);
    }
}

From source file:org.cauldron.tests.util.DigesterContext.java

public Object unmarshal(Node arg0) throws JAXBException {
    throw new JAXBException("unmarshal(Node) not yet implemented");
}

From source file:org.dasein.cloud.azure.tests.compute.vm.AzureVmTest.java

@Test(expected = InternalException.class)
public void startShouldThrowExceptionIfDeserializationFails() throws CloudException, InternalException {
    new MockUp<CloseableHttpClient>() {
        @Mock(invocations = 1)/*w w  w  .j a  v a2s . c  om*/
        public CloseableHttpResponse execute(HttpUriRequest request) throws JAXBException {
            throw new JAXBException("Deserialization failed");
        }
    };

    AzureVMSupport azureVMSupport = new AzureVMSupport(azureMock, getTestVirtualMachine());
    azureVMSupport.start(VM_ID);
}