Package org.apache.tomcat.util.descriptor

Examples of org.apache.tomcat.util.descriptor.XmlErrorHandler


        defaults.add(getDefaultWebXmlFragment());
        webxml.merge(defaults);

        Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(), true);

        XmlErrorHandler handler = new XmlErrorHandler();
        digester.setErrorHandler(handler);

        // System.out.print(webxml.toXml() + "\n\n\n");

        InputSource is = new InputSource(new StringReader(webxml.toXml()));
        WebXml webxmlResult = new WebXml();
        digester.push(webxmlResult);
        digester.parse(is);

        Assert.assertEquals(0, handler.getErrors().size());
        Assert.assertEquals(0, handler.getWarnings().size());

        Assert.assertEquals(version, webxml.getVersion());
        Assert.assertEquals(version, webxmlResult.getVersion());
    }
View Full Code Here


        webXmlDefaultFragment.setOverridable(true);
        webXmlDefaultFragment.setDistributable(true);
        webXmlDefaultFragment.setAlwaysAddWelcomeFiles(false);

        Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(), true);
        XmlErrorHandler handler = new XmlErrorHandler();
        digester.setErrorHandler(handler);
        digester.push(webXmlDefaultFragment);
        digester.parse(globalWebXml);
        Assert.assertEquals(0, handler.getErrors().size());
        Assert.assertEquals(0, handler.getWarnings().size());

        webXmlDefaultFragment.setReplaceWelcomeFiles(true);

        // Assert that web.xml was parsed and is not empty. Default servlet is known to be there.
        Assert.assertNotNull(webXmlDefaultFragment.getServlets().get("default"));
View Full Code Here

                InputStream stream = null;
                try {
                    stream = context.getServletContext().getResourceAsStream(
                            resourcePath);
                    if (stream != null) {
                        XmlErrorHandler handler = tldScanStream(stream);
                        handler.logFindings(log, resourcePath);
                        taglibUris.add(descriptor.getTaglibURI());
                        webxmlTaglibUris.add(descriptor.getTaglibURI());
                    } else {
                        log.warn(sm.getString("tldConfig.webxmlFailPathDoesNotExist", resourcePath,
                                descriptor.getTaglibURI()));
View Full Code Here

                            !path.endsWith("implicit.tld")) {
                        continue;
                    }
                    InputStream stream = ctxt.getResourceAsStream(path);
                    try {
                        XmlErrorHandler handler = tldScanStream(stream);
                        handler.logFindings(log, path);
                    } catch (IOException ioe) {
                        log.warn(sm.getString("tldConfig.webinfFail", path),
                                ioe);
                    } finally {
                        if (stream != null) {
View Full Code Here

                    tldScanDir(fileList[i]);
                } else if (fileList[i].getAbsolutePath().endsWith(TLD_EXT)) {
                    InputStream stream = null;
                    try {
                        stream = new FileInputStream(fileList[i]);
                        XmlErrorHandler handler = tldScanStream(stream);
                        handler.logFindings(log, fileList[i].getAbsolutePath());
                    } catch (IOException ioe) {
                        log.warn(sm.getString("tldConfig.dirFail",
                                fileList[i].getAbsolutePath()),
                                ioe);
                    } finally {
View Full Code Here

                if (entryName.startsWith("META-INF/") &&
                        entryName.endsWith(".tld")) {
                    is = null;
                    try {
                        is = jar.getEntryInputStream();
                        XmlErrorHandler handler = tldScanStream(is);
                        handler.logFindings(log, jarConn.getURL() + entryName);
                    } finally {
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException ioe) {
View Full Code Here

    private XmlErrorHandler tldScanStream(InputStream resourceStream)
            throws IOException {
       
        InputSource source = new InputSource(resourceStream);
       
        XmlErrorHandler result = new XmlErrorHandler();
       
        synchronized (tldDigester) {
            try {
                tldDigester.setErrorHandler(result);
                tldDigester.push(this);
View Full Code Here

                    is.setByteStream(stream);
                    if (context instanceof StandardContext) {
                        ((StandardContext) context).setReplaceWelcomeFiles(true);
                    }

                    XmlErrorHandler handler = new XmlErrorHandler();

                    webDigester.push(context);
                    webDigester.setErrorHandler(handler);

                    if(log.isDebugEnabled()) {
                        log.debug("Parsing application web.xml file at " + url.toExternalForm());
                    }

                    webDigester.parse(is);

                    if (handler.getWarnings().size() > 0 ||
                            handler.getErrors().size() > 0) {
                        ok = false;
                        handler.logFindings(log, is.getSystemId());
                    }
                } else {
                    log.info("No web.xml, using defaults " + context );
                }
            } catch (SAXParseException e) {
View Full Code Here

                if (context instanceof StandardContext)
                    ((StandardContext) context).setReplaceWelcomeFiles(true);
                digester.setClassLoader(this.getClass().getClassLoader());
                digester.setUseContextClassLoader(false);
                XmlErrorHandler handler = new XmlErrorHandler();
                digester.push(context);
                digester.setErrorHandler(handler);
                digester.parse(source);
                if (handler.getWarnings().size() > 0 ||
                        handler.getErrors().size() > 0) {
                    ok = false;
                    handler.logFindings(log, source.getSystemId());
                }
            } catch (SAXParseException e) {
                log.error(sm.getString("contextConfig.defaultParse"), e);
                log.error(sm.getString("contextConfig.defaultPosition",
                                 "" + e.getLineNumber(),
View Full Code Here

                }
                if (log.isTraceEnabled()) {
                    log.trace("  Processing TLD at '" + name + "'");
                }
                try {
                    XmlErrorHandler handler = tldScanStream(
                            new InputSource(jarFile.getInputStream(entry)));
                    handler.logFindings(log, "[" + name + "] in [" +
                            file.getAbsolutePath() + "]");
                } catch (Exception e) {
                    log.error(sm.getString("contextConfig.tldEntryException",
                                           name, jarPath, context.getPath()),
                              e);
View Full Code Here

TOP

Related Classes of org.apache.tomcat.util.descriptor.XmlErrorHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.