Example usage for java.lang VerifyError toString

List of usage examples for java.lang VerifyError toString

Introduction

In this page you can find the example usage for java.lang VerifyError toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.lsc.configuration.JaxbXmlConfigurationHelper.java

/**
 * Load an XML file to the object/*from w  w w .  j a  v  a  2 s. co m*/
 * 
 * @param filename
 *            filename to read from
 * @return the completed configuration object
 * @throws FileNotFoundException
 *             thrown if the file can not be accessed (either because of a
 *             misconfiguration or due to a rights issue)
 * @throws LscConfigurationException 
 */
public Lsc getConfiguration(String filename) throws LscConfigurationException {
    LOGGER.debug("Loading XML configuration from: " + filename);
    try {
        Unmarshaller unmarshaller = jaxbc.createUnmarshaller();
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema lscSchema = null;
        try {
            int i = 0;
            Set<URL> urls = new HashSet<URL>();
            urls.addAll(ClasspathHelper.forPackage("org.lsc"));
            if (System.getProperty("LSC.PLUGINS.PACKAGEPATH") != null) {
                String[] pathElements = System.getProperty("LSC.PLUGINS.PACKAGEPATH")
                        .split(System.getProperty("path.separator"));
                for (String pathElement : pathElements) {
                    urls.addAll(ClasspathHelper.forPackage(pathElement));
                }
            }
            Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(urls)
                    .setScanners(new ResourcesScanner(), new SubTypesScanner()));

            Set<String> xsdFiles = reflections.getResources(Pattern.compile(".*\\.xsd"));
            Source[] schemasSource = new Source[xsdFiles.size()];
            List<String> xsdFilesList = new ArrayList<String>(xsdFiles);
            Collections.reverse(xsdFilesList);
            for (String schemaFile : xsdFilesList) {
                LOGGER.debug("Importing XML schema file: " + schemaFile);
                InputStream schemaStream = this.getClass().getClassLoader().getResourceAsStream(schemaFile);
                schemasSource[i++] = new StreamSource(schemaStream);
            }
            lscSchema = schemaFactory.newSchema(schemasSource);
            unmarshaller.setSchema(lscSchema);

        } catch (VerifyError e) {
            throw new LscConfigurationException(e.toString(), e);
        } catch (SAXException e) {
            throw new LscConfigurationException(e);
        }

        return (Lsc) unmarshaller.unmarshal(new File(filename));
    } catch (JAXBException e) {
        throw new LscConfigurationException(e);
    }
}