Example usage for javax.xml.bind JAXBException getMessage

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.spend.spendService.SearchText.java

private SearchEngines getSearchEnginesFromXml() {
    try {/*from   w  ww.j  a v a2s  .com*/
        File file = new File("SearchEngines.xml");
        JAXBContext jaxbContext = JAXBContext.newInstance(SearchEngines.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        SearchEngines searchEngineList = (SearchEngines) jaxbUnmarshaller.unmarshal(file);
        return searchEngineList;
    } catch (JAXBException ex) {
        System.out.println("SearchText.java getSearchEnginesFromXml function ERROR " + ex.getMessage());
        ex.printStackTrace();
    }
    return null;
}

From source file:org.jvoicexml.callmanager.mmi.http.HttpETLProtocolAdapter.java

@Override
public void sendMMIEvent(Object channel, Mmi mmi) throws IOException {
    try {//from w ww  . j av  a  2s.  c  o  m
        final URI source = server.getURI();
        final LifeCycleEvent event = mmi.getLifeCycleEvent();
        event.setSource(source.toString());
        final String target = event.getTarget();
        if (target == null) {
            LOGGER.error("unable to send MMI event '" + mmi + "'. No target.");
            return;
        }
        final JAXBContext ctx = JAXBContext.newInstance(Mmi.class);
        final Marshaller marshaller = ctx.createMarshaller();
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        marshaller.marshal(mmi, out);
        final URI uri = new URI(target);
        final HttpClient client = new DefaultHttpClient();
        final HttpPost post = new HttpPost(uri);
        final HttpEntity entity = new StringEntity(out.toString(), ContentType.APPLICATION_XML);
        post.setEntity(entity);
        client.execute(post);
        LOGGER.info("sending " + mmi + " to '" + uri + "'");
    } catch (JAXBException e) {
        throw new IOException(e.getMessage(), e);
    } catch (URISyntaxException e) {
        throw new IOException(e.getMessage(), e);
    }
}

From source file:io.onedecision.engine.decisions.impl.DecisionModelFactory.java

@Override
public void write(Definitions dm, Writer out) throws IOException {
    JAXBContext context;/*from  w  w  w . ja  va 2  s. co  m*/
    try {
        context = JAXBContext.newInstance(Definitions.class);
        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

        // Since no @XmlRootElement generated for Definitions need to create
        // element wrapper here. See
        // https://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
        m.marshal(new JAXBElement<Definitions>(DEFINITIONS, Definitions.class, dm), out);
    } catch (JAXBException e) {
        throw new IOException(e.getMessage(), e);
    }
}

From source file:org.mitre.stixwebtools.services.TaxiiService.java

public String getTaxxiCollections(URI serverUrl) {
    HttpClient taxiiClient = getTaxiiClient("gatekeeper.mitre.org", 80);
    ObjectFactory factory = new ObjectFactory();
    String content;/*from w  ww.  j a va2  s  .c  o m*/

    CollectionInformationRequest request = factory.createCollectionInformationRequest()
            .withMessageId(MessageHelper.generateMessageId());

    try {

        Object responseObj = taxiiClient.callTaxiiService(serverUrl, request);
        content = taxiiXml.marshalToString(responseObj, true);
    } catch (JAXBException e) {
        content = e.getMessage();
    } catch (UnsupportedEncodingException eee) {
        content = eee.getMessage();
    } catch (IOException eeee) {
        content = eeee.getMessage();
    }

    return content;

}

From source file:org.mitre.stixwebtools.services.TaxiiService.java

/**
 * Query a Taxii server to get a list of availbe services this server supplies.
 * Expected results Discovery, Inbox, poll
 * /* w w w .  ja v  a  2s. c  om*/
 * @param serverUrl
 * @return 
 */
public String getTaxiiServices(URI serverUrl) {

    HttpClient taxiiClient = getTaxiiClient("gatekeeper.mitre.org", 80);

    String content;

    ObjectFactory factory = new ObjectFactory();

    DiscoveryRequest request = factory.createDiscoveryRequest()
            .withMessageId(MessageHelper.generateMessageId());

    try {

        Object responseObj = taxiiClient.callTaxiiService(serverUrl, request);
        content = taxiiXml.marshalToString(responseObj, true);
    } catch (JAXBException e) {
        content = e.getMessage();
    } catch (UnsupportedEncodingException eee) {
        content = eee.getMessage();
    } catch (IOException eeee) {
        content = eeee.getMessage();
    }

    return content;
}

From source file:jails.http.converter.xml.AbstractJaxb2HttpMessageConverter.java

/**
 * Creates a new {@link Marshaller} for the given class.
 *
 * @param clazz the class to create the marshaller for
 * @return the {@code Marshaller}/*  ww  w  .  j  a v a2s. c om*/
 * @throws HttpMessageConversionException in case of JAXB errors
 */
protected final Marshaller createMarshaller(Class clazz) {
    try {
        JAXBContext jaxbContext = getJaxbContext(clazz);
        return jaxbContext.createMarshaller();
    } catch (JAXBException ex) {
        throw new HttpMessageConversionException(
                "Could not create Marshaller for class [" + clazz + "]: " + ex.getMessage(), ex);
    }
}

From source file:jails.http.converter.xml.AbstractJaxb2HttpMessageConverter.java

/**
 * Creates a new {@link Unmarshaller} for the given class.
 *
 * @param clazz the class to create the unmarshaller for
 * @return the {@code Unmarshaller}/*from   w w w  .j  a  v a  2 s  . c  om*/
 * @throws HttpMessageConversionException in case of JAXB errors
 */
protected final Unmarshaller createUnmarshaller(Class clazz) throws JAXBException {
    try {
        JAXBContext jaxbContext = getJaxbContext(clazz);
        return jaxbContext.createUnmarshaller();
    } catch (JAXBException ex) {
        throw new HttpMessageConversionException(
                "Could not create Unmarshaller for class [" + clazz + "]: " + ex.getMessage(), ex);
    }
}

From source file:com.spend.spendService.DomainLearning.java

private SearchEngines getSearchEnginesFromXml() {
    try {//from  w  w w  .  j a  v a 2  s.c o m
        File file = new File("SearchEngines.xml");
        JAXBContext jaxbContext = JAXBContext.newInstance(SearchEngines.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        SearchEngines searchEngineList = (SearchEngines) jaxbUnmarshaller.unmarshal(file);
        return searchEngineList;
    } catch (JAXBException ex) {
        System.out.println("DomainLearning.java getSearchEnginesFromXml function ERROR " + ex.getMessage());
        ex.printStackTrace();
    }
    return null;
}

From source file:jails.http.converter.xml.AbstractJaxb2HttpMessageConverter.java

/**
 * Returns a {@link JAXBContext} for the given class.
 *
 * @param clazz the class to return the context for
 * @return the {@code JAXBContext}/*from  ww w . j  a v a 2s . c  o  m*/
 * @throws HttpMessageConversionException in case of JAXB errors
 */
protected final JAXBContext getJaxbContext(Class clazz) {
    Assert.notNull(clazz, "'clazz' must not be null");
    JAXBContext jaxbContext = jaxbContexts.get(clazz);
    if (jaxbContext == null) {
        try {
            jaxbContext = JAXBContext.newInstance(clazz);
            jaxbContexts.putIfAbsent(clazz, jaxbContext);
        } catch (JAXBException ex) {
            throw new HttpMessageConversionException(
                    "Could not instantiate JAXBContext for class [" + clazz + "]: " + ex.getMessage(), ex);
        }
    }
    return jaxbContext;
}

From source file:be.fedict.eid.applet.service.signer.ooxml.OPCKeySelector.java

public OPCKeySelector(URL opcUrl, String signatureResourceName) {
    this.opcUrl = opcUrl;
    this.signatureResourceName = signatureResourceName;

    try {//from   w  w  w  . j a  v  a2s .com
        JAXBContext relationshipsJAXBContext = JAXBContext.newInstance(ObjectFactory.class);
        this.relationshipsUnmarshaller = relationshipsJAXBContext.createUnmarshaller();
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }

    try {
        this.certificateFactory = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new RuntimeException("CertificateFactory error: " + e.getMessage(), e);
    }
}