Search in sources :

Example 36 with JAXBException

use of javax.xml.bind.JAXBException in project spring-framework by spring-projects.

the class Jaxb2Marshaller method createUnmarshaller.

/**
	 * Return a newly created JAXB unmarshaller.
	 * Note: JAXB unmarshallers are not necessarily thread-safe.
	 */
protected Unmarshaller createUnmarshaller() {
    try {
        Unmarshaller unmarshaller = getJaxbContext().createUnmarshaller();
        initJaxbUnmarshaller(unmarshaller);
        return unmarshaller;
    } catch (JAXBException ex) {
        throw convertJaxbException(ex);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) MimeUnmarshaller(org.springframework.oxm.mime.MimeUnmarshaller) AttachmentUnmarshaller(javax.xml.bind.attachment.AttachmentUnmarshaller) GenericUnmarshaller(org.springframework.oxm.GenericUnmarshaller) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 37 with JAXBException

use of javax.xml.bind.JAXBException in project spring-framework by spring-projects.

the class Jaxb2Marshaller method createMarshaller.

/**
	 * Return a newly created JAXB marshaller. JAXB marshallers are not necessarily thread safe.
	 */
protected Marshaller createMarshaller() {
    try {
        Marshaller marshaller = getJaxbContext().createMarshaller();
        initJaxbMarshaller(marshaller);
        return marshaller;
    } catch (JAXBException ex) {
        throw convertJaxbException(ex);
    }
}
Also used : GenericMarshaller(org.springframework.oxm.GenericMarshaller) MimeMarshaller(org.springframework.oxm.mime.MimeMarshaller) Marshaller(javax.xml.bind.Marshaller) AttachmentMarshaller(javax.xml.bind.attachment.AttachmentMarshaller) JAXBException(javax.xml.bind.JAXBException)

Example 38 with JAXBException

use of javax.xml.bind.JAXBException in project play-cookbook by spinscale.

the class ApiPlugin method onApplicationStart.

@Override
public void onApplicationStart() {
    try {
        List<ApplicationClass> applicationClasses = Play.classes.getAnnotatedClasses(XmlRootElement.class);
        List<Class> classes = new ArrayList<Class>();
        for (ApplicationClass applicationClass : applicationClasses) {
            classes.add(applicationClass.javaClass);
        }
        jc = JAXBContext.newInstance(classes.toArray(new Class[] {}));
    } catch (JAXBException e) {
        Logger.error(e, "Problem initializing jaxb context: %s", e.getMessage());
    }
    gson = new GsonBuilder().create();
    Logger.info("ApiPlugin loaded");
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass)

Example 39 with JAXBException

use of javax.xml.bind.JAXBException in project play-cookbook by spinscale.

the class ApiPlugin method onApplicationStart.

public void onApplicationStart() {
    Logger.info("ApiPlugin loaded");
    try {
        List<ApplicationClass> applicationClasses = Play.classes.getAnnotatedClasses(XmlRootElement.class);
        List<Class> classes = new ArrayList<Class>();
        for (ApplicationClass applicationClass : applicationClasses) {
            classes.add(applicationClass.javaClass);
        }
        jc = JAXBContext.newInstance(classes.toArray(new Class[] {}));
    } catch (JAXBException e) {
        Logger.error(e, "Problem initializing jaxb context: %s", e.getMessage());
    }
    gson = new GsonBuilder().create();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass)

Example 40 with JAXBException

use of javax.xml.bind.JAXBException in project play-cookbook by spinscale.

the class ApiPlugin method getXml.

private Object getXml(Class clazz) {
    try {
        if (clazz.getAnnotation(XmlRootElement.class) != null) {
            Unmarshaller um = jc.createUnmarshaller();
            StringReader sr = new StringReader(Request.current().params.get("body"));
            return um.unmarshal(sr);
        }
    } catch (JAXBException e) {
        Logger.error("Problem rendering XML: %s", e.getMessage());
    }
    return null;
}
Also used : XmlRootElement(javax.xml.bind.annotation.XmlRootElement) JAXBException(javax.xml.bind.JAXBException) StringReader(java.io.StringReader) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

JAXBException (javax.xml.bind.JAXBException)402 JAXBContext (javax.xml.bind.JAXBContext)126 IOException (java.io.IOException)93 Unmarshaller (javax.xml.bind.Unmarshaller)91 Marshaller (javax.xml.bind.Marshaller)69 ArrayList (java.util.ArrayList)38 StringWriter (java.io.StringWriter)35 List (java.util.List)35 Map (java.util.Map)33 SAXException (org.xml.sax.SAXException)32 File (java.io.File)29 InputStream (java.io.InputStream)29 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)28 HashSet (java.util.HashSet)28 JAXBElement (javax.xml.bind.JAXBElement)24 XMLStreamException (javax.xml.stream.XMLStreamException)23 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)22 StringReader (java.io.StringReader)21 HashMap (java.util.HashMap)21 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)20