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:org.ets.ereg.web.util.CRSContentUploadThread.java

/**
 * Marshalls from object to XML input stream
 *///from  ww  w  .  j  av  a  2s. c  o m
private void marshall(JAXBElement<TMrss> jaxbElement, File xmlFile) {
    try {
        Marshaller marshaller = JAXBContext.newInstance(TMrss.class).createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "");

        marshaller.marshal(jaxbElement, xmlFile);
    } catch (JAXBException e) {
        log.error(e.getMessage(), e);
    }
}

From source file:org.excalibur.core.util.JAXBContextFactory.java

public final String marshalQuietly(Object obj) {
    if (obj == null) {
        LOG.debug("Type to marshall was null. Returning null...");
        return null;
    }/*from ww w  .  jav  a  2 s. c o  m*/

    try {
        return marshal(obj);
    } catch (JAXBException e) {
        LOG.warn(e.getMessage(), e);
        return null;
    }
}

From source file:org.fastcatsearch.ir.IRService.java

protected boolean doStart() throws FastcatSearchException {

    try {//from  www. j a va  2s  .c  o m
        realtimeQueryStatisticsModule.load();
    } catch (Throwable t) {
        ClusterAlertService.getInstance().alert(t);
    }
    collectionHandlerMap = new ConcurrentHashMap<String, CollectionHandler>();
    // collections ? ?.
    collectionsRoot = environment.filePaths().getCollectionsRoot().file();

    try {
        collectionsConfig = JAXBConfigs.readConfig(new File(collectionsRoot, SettingFileNames.collections),
                CollectionsConfig.class);
    } catch (JAXBException e) {
        logger.error("[ERROR] fail to read collection config. " + e.getMessage(), e);
        ClusterAlertService.getInstance().alert(e);
    }

    try {
        jdbcSourceConfig = JAXBConfigs.readConfig(new File(collectionsRoot, SettingFileNames.jdbcSourceConfig),
                JDBCSourceConfig.class);
    } catch (JAXBException e) {
        logger.error("[ERROR] fail to read jdbc source list. " + e.getMessage(), e);
        ClusterAlertService.getInstance().alert(e);
    }

    if (jdbcSourceConfig == null) {
        jdbcSourceConfig = new JDBCSourceConfig();
    }

    try {
        jdbcSupportConfig = JAXBConfigs.readConfig(
                new File(collectionsRoot, SettingFileNames.jdbcSupportConfig), JDBCSupportConfig.class);
    } catch (JAXBException e) {
        logger.error("[ERROR] fail to read jdbc support. " + e.getMessage(), e);
        ClusterAlertService.getInstance().alert(e);
    }

    if (jdbcSupportConfig == null) {
        jdbcSupportConfig = new JDBCSupportConfig();
    }

    File file = environment.filePaths().configPath().file(SettingFileNames.searchPageSettings);
    if (file.exists()) {
        try {
            searchPageSettings = JAXBConfigs.readConfig(file, SearchPageSettings.class);
        } catch (JAXBException e) {
            logger.error("[ERROR] fail to read search page settings. " + e.getMessage(), e);
            ClusterAlertService.getInstance().alert(e);
        }
    } else {
        searchPageSettings = new SearchPageSettings();
    }

    dataNodeCollectionIdSet = new HashSet<String>();

    List<Collection> collectionList = collectionsConfig.getCollectionList();
    for (int collectionInx = 0; collectionInx < collectionList.size(); collectionInx++) {
        Collection collection = collectionList.get(collectionInx);
        try {
            String collectionId = collection.getId();
            loadCollectionHandler(collectionId, collection);
        } catch (Throwable e) {
            logger.error("[ERROR] " + e.getMessage(), e);
        }
    }
    try {
        //?  xml ? .
        JAXBConfigs.writeConfig(new File(collectionsRoot, SettingFileNames.collections), collectionsConfig,
                CollectionsConfig.class);
    } catch (JAXBException e) {
        logger.error("", e);
        ClusterAlertService.getInstance().alert(e);
    }

    searchCache = new QueryCacheModule<String, Result>(environment, settings);
    shardSearchCache = new QueryCacheModule<String, InternalSearchResult>(environment, settings);
    groupingCache = new QueryCacheModule<String, GroupResults>(environment, settings);
    groupingDataCache = new QueryCacheModule<String, GroupsData>(environment, settings);
    documentCache = new QueryCacheModule<String, Result>(environment, settings);
    try {
        searchCache.load();
        shardSearchCache.load();
        groupingCache.load();
        groupingDataCache.load();
        documentCache.load();
    } catch (ModuleException e) {
        ClusterAlertService.getInstance().alert(e);
        throw new FastcatSearchException("ERR-00320");
    }

    return true;
}

From source file:org.fusesource.ide.generator.Generator.java

public Nodeset getXmlModel() {
    if (xmlModel == null) {
        try {//from w  w w .  j  a v a2s . co  m
            JAXBContext context = JAXBContext.newInstance(Nodeset.class);
            xmlModel = (Nodeset) context.createUnmarshaller().unmarshal(new StreamSource(
                    getClass().getResourceAsStream("/org/fusesource/ide/generator/model.xml")));
        } catch (JAXBException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    return xmlModel;
}

From source file:org.genericprodigy.rp.heroquest.classes.ClassMarshaller.java

/**
 * Marshals the {@link Model} object passed in to the {@code createInstance}
 * factory method into a new {@code MarshalledModel} entity object.
 *
 * @return {@link MarshalledModel} entity object with an XML representation
 * of the object state./*ww w .  ja v a  2 s.  co  m*/
 */
public MarshalledModel marshal() {

    MarshalledXml xml = new MarshalledXml();
    String data = null;

    try {
        JAXBContext context = JAXBContext.newInstance(this.model.getClass());
        Marshaller marshaller = context.createMarshaller();
        StringWriter sw = new StringWriter();
        marshaller.marshal(this.model, sw);
        data = sw.toString();
        log.debug("Output Xml = " + sw.toString());
    } catch (javax.xml.bind.PropertyException propEx) {
        log.error("javax.xml.bind.PropertyException caught: " + propEx.getMessage(), propEx);
        propEx.printStackTrace();
    } catch (javax.xml.bind.JAXBException jaxbEx) {
        log.error("javax.xml.bind.JAXBException caught: " + jaxbEx.getMessage(), jaxbEx);
        jaxbEx.printStackTrace();
    } catch (Exception ex) {
        log.error("Exception caught: " + ex.getMessage(), ex);
        ex.printStackTrace();
    }

    xml.setData(data);
    return xml;
}

From source file:org.genericprodigy.rp.heroquest.classes.ClassMarshaller.java

/**
 * Unmarshals the {@link MarshalledModel} entity object from XML to a
 * {@link Model} object complete with existing state.
 *
 * @param data Marshalled entity representation of the object.
 * @return Unmarshalled entity object complete with state.
 *//*w  ww . j av a  2s  . c o  m*/
public T unmarshal(MarshalledModel data) {

    MarshalledXml xml = (MarshalledXml) data;
    T response = null;

    try {
        JAXBContext context = JAXBContext.newInstance(this.model.getClass());
        Unmarshaller unmarshaller = context.createUnmarshaller();
        StringReader sr = new StringReader(xml.getData());
        this.model = (T) unmarshaller.unmarshal(sr);
    } catch (javax.xml.bind.PropertyException propEx) {
        log.error("javax.xml.bind.PropertyException caught: " + propEx.getMessage(), propEx);
        propEx.printStackTrace();
    } catch (javax.xml.bind.JAXBException jaxbEx) {
        log.error("javax.xml.bind.JAXBException caught: " + jaxbEx.getMessage(), jaxbEx);
        jaxbEx.printStackTrace();
    } catch (Exception ex) {
        log.error("Exception caught: " + ex.getMessage(), ex);
        ex.printStackTrace();
    }

    return this.model;

}

From source file:org.genericprodigy.rp.heroquest.XmlMarshaller.java

/**
 * Marshals the {@link Model} object passed in to the {@code createInstance}
 * factory method into a new {@code MarshalledModel} entity object.
 *
 * @return {@link MarshalledModel} entity object with an XML representation
 * of the object state./* ww w  .  j  a  va 2 s .com*/
 */
@Override
public MarshalledModel marshal() {
    MarshalledXml response = new MarshalledXml();

    String data = null;

    try {
        JAXBContext context = JAXBContext.newInstance(this.model.getClass());
        Marshaller marshaller = context.createMarshaller();
        StringWriter sw = new StringWriter();
        marshaller.marshal(this.model, sw);
        data = sw.toString();
        response.setData(data);
        log.debug("Output Xml = " + sw.toString());
    } catch (javax.xml.bind.PropertyException propEx) {
        log.error("javax.xml.bind.PropertyException caught: " + propEx.getMessage(), propEx);
        propEx.printStackTrace();
    } catch (javax.xml.bind.JAXBException jaxbEx) {
        log.error("javax.xml.bind.JAXBException caught: " + jaxbEx.getMessage(), jaxbEx);
        jaxbEx.printStackTrace();
    } catch (Exception ex) {
        log.error("Exception caught: " + ex.getMessage(), ex);
        ex.printStackTrace();
    }

    return (MarshalledModel) response;
}

From source file:org.genericprodigy.rp.heroquest.XmlMarshaller.java

/**
 * Unmarshals the {@link MarshalledModel} entity object from XML to a
 * {@link Model} object complete with existing state.
 *
 * @param data Marshalled entity representation of the object.
 * @return Unmarshalled entity object complete with state.
 *//*from   w w w. jav a2s.  c o  m*/
@Override
public T unmarshal(MarshalledModel data) {

    MarshalledXml xml = (MarshalledXml) data;
    T response = null;

    try {
        JAXBContext context = JAXBContext.newInstance(this.model.getClass());
        Unmarshaller unmarshaller = context.createUnmarshaller();
        StringReader sr = new StringReader(xml.getData());
        this.model = (T) unmarshaller.unmarshal(sr);
    } catch (javax.xml.bind.PropertyException propEx) {
        log.error("javax.xml.bind.PropertyException caught: " + propEx.getMessage(), propEx);
        propEx.printStackTrace();
    } catch (javax.xml.bind.JAXBException jaxbEx) {
        log.error("javax.xml.bind.JAXBException caught: " + jaxbEx.getMessage(), jaxbEx);
        jaxbEx.printStackTrace();
    } catch (Exception ex) {
        log.error("Exception caught: " + ex.getMessage(), ex);
        ex.printStackTrace();
    }

    return this.model;

}

From source file:org.geotools.gce.imagemosaic.ImageMosaicConfigHandler.java

/**
 * Default constructor/*from w  w w .j  a  v  a2 s  . c  o  m*/
 * 
 * @throws
 * @throws IllegalArgumentException
 */
public ImageMosaicConfigHandler(final CatalogBuilderConfiguration configuration,
        final ImageMosaicEventHandlers eventHandler) {
    Utilities.ensureNonNull("runConfiguration", configuration);

    Utilities.ensureNonNull("eventHandler", eventHandler);
    this.eventHandler = eventHandler;

    Indexer defaultIndexer = configuration.getIndexer();
    ParametersType params = null;
    String rootMosaicDir = null;
    if (defaultIndexer != null) {
        params = defaultIndexer.getParameters();
        rootMosaicDir = IndexerUtils.getParam(params, Prop.ROOT_MOSAIC_DIR);
        IndexerUtils.getParameterAsBoolean(Prop.USE_EXISTING_SCHEMA, defaultIndexer);
    }

    Utilities.ensureNonNull("root location", rootMosaicDir);

    // look for and indexer.properties file
    parent = new File(rootMosaicDir);
    indexerFile = new File(parent, Utils.INDEXER_XML);
    Indexer indexer = null;

    Hints hints = configuration.getHints();
    String ancillaryFile = null;
    if (Utils.checkFileReadable(indexerFile)) {
        try {
            indexer = (Indexer) Utils.unmarshal(indexerFile);
            if (indexer != null) {
                copyDefaultParams(params, indexer);
            }
        } catch (JAXBException e) {
            LOGGER.log(Level.WARNING, e.getMessage(), e);
        }
    } else {
        // Backward compatible with old indexing
        indexerFile = new File(parent, Utils.INDEXER_PROPERTIES);
        if (Utils.checkFileReadable(indexerFile)) {
            // load it and parse it
            final Properties props = Utils.loadPropertiesFromURL(DataUtilities.fileToURL(indexerFile));
            indexer = createIndexer(props, params);
        }
    }
    if (indexer != null) {
        // Overwrite default indexer only when indexer is available
        configuration.setIndexer(indexer);
        String param = IndexerUtils.getParameter(Utils.Prop.AUXILIARY_FILE, indexer);
        if (param != null) {
            ancillaryFile = param;
            setReader(hints, false);
        }
        if (IndexerUtils.getParameterAsBoolean(Utils.Prop.USE_EXISTING_SCHEMA, indexer)) {
            this.useExistingSchema = true;
        }
    }

    updateConfigurationHints(configuration, hints, ancillaryFile,
            IndexerUtils.getParam(params, Prop.ROOT_MOSAIC_DIR));

    // check config
    configuration.check();

    this.runConfiguration = new CatalogBuilderConfiguration(configuration);
}

From source file:org.jts.eclipse.ui.actions.importbinding.Util.java

/**
  * Filter jsidl files, unmarshal and place in a Map.
  * @param fileList list of JSIDL XML files containing service sets
  * @return A Map from service set ID/version strings to JAXB instances representing those service sets.
 * @throws JAXBException /*  w  w  w.  j  a va  2s  .c o m*/
 * @throws SAXException 
  */
public static Map getObjectMapFromFile(List<File> fileList, List<ServiceDef> tmp)
        throws JAXBException, SAXException {
    Map objMap = new HashMap();
    Document doc = null;
    DocumentBuilder db = null;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    Unmarshaller um = null;

    // Set up the unmarshaller with the schema included with the code
    // generator.
    try {
        JAXBContext jc = JAXBContext.newInstance("org.jts.jsidl.binding");
        um = jc.createUnmarshaller();
        SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

        Bundle bundle = CjsidlActivator.getInstance().getBundle();
        String schema_loc;
        if (new File(SCHEMA_PATH).exists()) {
            schema_loc = SCHEMA_PATH;
        } else if (new File(JTS_SCHEMA_PATH).exists()) {
            schema_loc = JTS_SCHEMA_PATH;
        } else if (new File(DEPLOYED_SCHEMA_PATH).exists()) {
            schema_loc = DEPLOYED_SCHEMA_PATH;
        } else {
            throw new Exception("Unable to find the schema path for jsidl_plus.xsd: "
                    + (new File(SCHEMA_PATH).getAbsolutePath()) + "\n\t"
                    + (new File(JTS_SCHEMA_PATH).getAbsolutePath()) + "\n\t"
                    + (new File(DEPLOYED_SCHEMA_PATH).getAbsolutePath()));
        }
        //         IPath path = new Path(schema_loc);
        //         URL schemaUrl = FileLocator.find(bundle, path,
        //               Collections.EMPTY_MAP);
        //         File schemaFile = new File(FileLocator.toFileURL(schemaUrl).toURI());
        File schemaFile = new File(schema_loc);
        Schema schema = sf.newSchema(schemaFile);
        um.setSchema(schema);

        // Try parsing each file.

        db = dbf.newDocumentBuilder();

        for (int ii = 0; ii < fileList.size(); ii++) {
            File file = fileList.get(ii);
            final String fileName = file.toString();

            doc = db.parse(file);

            Element root = doc.getDocumentElement();

            if (root.getAttribute("xmlns").equals("urn:jaus:jsidl:1.0")) {

                Object o = um.unmarshal(file);
                objMap.put(root.getAttribute("id") + "-" + root.getAttribute("version"), o);
                if (o instanceof ServiceDef) {
                    tmp.add((ServiceDef) o);
                }

            }
        }
    } catch (JAXBException jaxbe) {
        Logger.getLogger(ImportServiceSet.class.getName()).log(Level.SEVERE, jaxbe.getMessage(), jaxbe);
        throw jaxbe;
    } catch (SAXException saxe) {
        Logger.getLogger(ImportServiceSet.class.getName()).log(Level.SEVERE, saxe.getMessage(), saxe);
        throw saxe;
    } catch (URISyntaxException e) {
        Logger.getLogger(ImportServiceSet.class.getName()).log(Level.SEVERE, e.getMessage(), e);
    } catch (IOException e) {
        Logger.getLogger(ImportServiceSet.class.getName()).log(Level.SEVERE, e.getMessage(), e);
    } catch (ParserConfigurationException e) {
        Logger.getLogger(ImportServiceSet.class.getName()).log(Level.SEVERE, e.getMessage(), e);
    } catch (Exception e) {
        Logger.getLogger(ImportServiceSet.class.getName()).log(Level.SEVERE, e.getMessage(), e);
    }
    return objMap;
}