View | Details | Raw Unified | Return to bug 56438
Collapse All | Expand All

(-)java/org/apache/catalina/startup/ContextConfig.java (-2 / +24 lines)
Lines 1902-1908 Link Here
1902
        jarScanner.scan(context.getServletContext(),
1902
        jarScanner.scan(context.getServletContext(),
1903
                context.getLoader().getClassLoader(), callback,
1903
                context.getLoader().getClassLoader(), callback,
1904
                pluggabilityJarsToSkip);
1904
                pluggabilityJarsToSkip);
1905
1905
        
1906
        if(callback.scanFoundNoFragments()){
1907
        	log.info(sm.getString("contextConfig.NoFragmentSummary"));
1908
        }
1909
        
1906
        return callback.getFragments();
1910
        return callback.getFragments();
1907
    }
1911
    }
1908
1912
Lines 2629-2635 Link Here
2629
            "META-INF/web-fragment.xml";
2633
            "META-INF/web-fragment.xml";
2630
        private Map<String,WebXml> fragments = new HashMap<String,WebXml>();
2634
        private Map<String,WebXml> fragments = new HashMap<String,WebXml>();
2631
        private final boolean parseRequired;
2635
        private final boolean parseRequired;
2632
2636
        private boolean fragmentFound = false;
2637
        
2633
        public FragmentJarScannerCallback(boolean parseRequired) {
2638
        public FragmentJarScannerCallback(boolean parseRequired) {
2634
            this.parseRequired = parseRequired;
2639
            this.parseRequired = parseRequired;
2635
        }
2640
        }
Lines 2654-2659 Link Here
2654
                    // impact on distributable
2659
                    // impact on distributable
2655
                    fragment.setDistributable(true);
2660
                    fragment.setDistributable(true);
2656
                } else {
2661
                } else {
2662
                	fragmentFound = true;
2657
                    InputSource source = new InputSource(
2663
                    InputSource source = new InputSource(
2658
                            "jar:" + resourceURL.toString() + "!/" +
2664
                            "jar:" + resourceURL.toString() + "!/" +
2659
                            FRAGMENT_LOCATION);
2665
                            FRAGMENT_LOCATION);
Lines 2671-2676 Link Here
2671
                fragment.setJarName(extractJarFileName(url));
2677
                fragment.setJarName(extractJarFileName(url));
2672
                fragments.put(fragment.getName(), fragment);
2678
                fragments.put(fragment.getName(), fragment);
2673
            }
2679
            }
2680
            
2681
            if (log.isDebugEnabled()) {
2682
            	if(!fragmentFound){
2683
                	log.debug(sm.getString("contextConfig.NoFragmentInJar", resourceURL.toString()));
2684
                }
2685
            }            
2674
        }
2686
        }
2675
2687
2676
        private String extractJarFileName(URL input) {
2688
        private String extractJarFileName(URL input) {
Lines 2693-2698 Link Here
2693
            try {
2705
            try {
2694
                File fragmentFile = new File(file, FRAGMENT_LOCATION);
2706
                File fragmentFile = new File(file, FRAGMENT_LOCATION);
2695
                if (fragmentFile.isFile()) {
2707
                if (fragmentFile.isFile()) {
2708
                	fragmentFound = true;
2696
                    stream = new FileInputStream(fragmentFile);
2709
                    stream = new FileInputStream(fragmentFile);
2697
                    InputSource source =
2710
                    InputSource source =
2698
                        new InputSource(fragmentFile.toURI().toURL().toString());
2711
                        new InputSource(fragmentFile.toURI().toURL().toString());
Lines 2717-2727 Link Here
2717
                fragment.setJarName(file.getName());
2730
                fragment.setJarName(file.getName());
2718
                fragments.put(fragment.getName(), fragment);
2731
                fragments.put(fragment.getName(), fragment);
2719
            }
2732
            }
2733
            if (log.isDebugEnabled()) {
2734
            	if(!fragmentFound){
2735
                	log.debug(sm.getString("contextConfig.NoFragmentInFile", file.getAbsolutePath()));
2736
                }
2737
            }
2720
        }
2738
        }
2721
2739
2722
        public Map<String,WebXml> getFragments() {
2740
        public Map<String,WebXml> getFragments() {
2723
            return fragments;
2741
            return fragments;
2724
        }
2742
        }
2743
        
2744
        public boolean scanFoundNoFragments(){
2745
        	return !fragmentFound;
2746
        }
2725
    }
2747
    }
2726
2748
2727
    private static class DefaultWebXmlCacheEntry {
2749
    private static class DefaultWebXmlCacheEntry {
(-)java/org/apache/catalina/startup/LocalStrings.properties (+6 lines)
Lines 68-73 Link Here
68
contextConfig.urlPatternValue=Both the UrlPattern and value attribute were set for the WebServlet annotation on class [{0}]
68
contextConfig.urlPatternValue=Both the UrlPattern and value attribute were set for the WebServlet annotation on class [{0}]
69
contextConfig.webinfClassesUrl=Unable to determine URL for [{0}]
69
contextConfig.webinfClassesUrl=Unable to determine URL for [{0}]
70
contextConfig.xmlSettings=Context [{0}] will parse web.xml and web-fragment.xml files with validation:{1} and namespaceAware:{2}
70
contextConfig.xmlSettings=Context [{0}] will parse web.xml and web-fragment.xml files with validation:{1} and namespaceAware:{2}
71
contextConfig.NoFragmentInJar=No fragments were found in [{0}]. Consider adding the JAR to the org.apache.catalina.startup.ContextConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
72
contextConfig.NoFragmentInFile=No fragments were found in [{0}]. Consider adding the File to the org.apache.catalina.startup.ContextConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
73
contextConfig.NoFragmentSummary=At least one JAR was scanned for fragments yet contained no fragments. Enable debug logging for this logger for a complete list of JARs that were scanned but no fragments were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
71
embedded.noEngines=No engines have been defined yet
74
embedded.noEngines=No engines have been defined yet
72
embedded.notmp=Cannot find specified temporary folder at {0}
75
embedded.notmp=Cannot find specified temporary folder at {0}
73
embedded.authenticatorNotInstanceOfValve=Specified Authenticator is not a Valve
76
embedded.authenticatorNotInstanceOfValve=Specified Authenticator is not a Valve
Lines 124-131 Link Here
124
tldConfig.cce=Lifecycle event data object {0} is not a Context
127
tldConfig.cce=Lifecycle event data object {0} is not a Context
125
tldConfig.dirFail=Failed to process directory [{0}] for TLD files
128
tldConfig.dirFail=Failed to process directory [{0}] for TLD files
126
tldConfig.dirScan=Scanning for TLD files in directory [{0}]
129
tldConfig.dirScan=Scanning for TLD files in directory [{0}]
130
tldConfig.noTldInDir=No TLD files were found in directory [{0}].
127
tldConfig.execute=Error processing TLD files for context with name [{0}]
131
tldConfig.execute=Error processing TLD files for context with name [{0}]
128
tldConfig.jarFail=Failed to process JAR [{0}] for TLD files
132
tldConfig.jarFail=Failed to process JAR [{0}] for TLD files
133
tldConfig.noTldInJar=No TLD files were found in [{0}]. Consider adding the JAR to the org.apache.catalina.startup.TldConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
134
tldConfig.noTldSummary=At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
129
tldConfig.webinfFail=Failed to process TLD found at [{0}]
135
tldConfig.webinfFail=Failed to process TLD found at [{0}]
130
tldConfig.webinfScan=Scanning WEB-INF for TLD files in [{0}]
136
tldConfig.webinfScan=Scanning WEB-INF for TLD files in [{0}]
131
tldConfig.webxmlAdd=Adding path [{0}] for URI [{1}]
137
tldConfig.webxmlAdd=Adding path [{0}] for URI [{1}]
(-)java/org/apache/catalina/startup/TldConfig.java (-9 / +35 lines)
Lines 266-275 Link Here
266
266
267
        // Stages 3b & 4
267
        // Stages 3b & 4
268
        JarScanner jarScanner = context.getJarScanner();
268
        JarScanner jarScanner = context.getJarScanner();
269
        
270
        TldJarScannerCallback objCallBack = new TldJarScannerCallback();
269
        jarScanner.scan(context.getServletContext(),
271
        jarScanner.scan(context.getServletContext(),
270
                context.getLoader().getClassLoader(),
272
                context.getLoader().getClassLoader(),
271
                new TldJarScannerCallback(), noTldJars);
273
                objCallBack, noTldJars);
272
        
274
        
275
        if(objCallBack.scanFoundNoTLDs()){
276
        	log.info(sm.getString("tldConfig.noTldSummary"));
277
        }
278
        
273
        // Now add all the listeners we found to the listeners for this context
279
        // Now add all the listeners we found to the listeners for this context
274
        String list[] = getTldListeners();
280
        String list[] = getTldListeners();
275
281
Lines 290-299 Link Here
290
    }
296
    }
291
297
292
    private class TldJarScannerCallback implements JarScannerCallback {
298
    private class TldJarScannerCallback implements JarScannerCallback {
293
299
    	boolean tldFound = false;
300
    	
294
        @Override
301
        @Override
295
        public void scan(JarURLConnection urlConn) throws IOException {
302
        public void scan(JarURLConnection urlConn) throws IOException {
296
            tldScanJar(urlConn);
303
        	tldFound = tldScanJar(urlConn);
297
        }
304
        }
298
305
299
        @Override
306
        @Override
Lines 300-308 Link Here
300
        public void scan(File file) {
307
        public void scan(File file) {
301
            File metaInf = new File(file, "META-INF");
308
            File metaInf = new File(file, "META-INF");
302
            if (metaInf.isDirectory()) {
309
            if (metaInf.isDirectory()) {
303
                tldScanDir(metaInf);
310
            	tldFound = tldScanDir(metaInf);
304
            }
311
            }
305
        }
312
        }
313
        
314
        private boolean scanFoundNoTLDs() {
315
            return !tldFound;
316
        }
306
    }
317
    }
307
318
308
    // -------------------------------------------------------- Private Methods
319
    // -------------------------------------------------------- Private Methods
Lines 432-439 Link Here
432
     *
443
     *
433
     * Keep in sync with o.a.j.comiler.TldLocationsCache
444
     * Keep in sync with o.a.j.comiler.TldLocationsCache
434
     */
445
     */
435
    private void tldScanDir(File start) {
446
    private boolean tldScanDir(File start) {
436
447
    	boolean isFound = false;
437
        if (log.isTraceEnabled()) {
448
        if (log.isTraceEnabled()) {
438
            log.trace(sm.getString("tldConfig.dirScan", start.getAbsolutePath()));
449
            log.trace(sm.getString("tldConfig.dirScan", start.getAbsolutePath()));
439
        }
450
        }
Lines 446-451 Link Here
446
                    tldScanDir(fileList[i]);
457
                    tldScanDir(fileList[i]);
447
                } else if (fileList[i].getAbsolutePath().endsWith(TLD_EXT)) {
458
                } else if (fileList[i].getAbsolutePath().endsWith(TLD_EXT)) {
448
                    InputStream stream = null;
459
                    InputStream stream = null;
460
                    isFound = true;
449
                    try {
461
                    try {
450
                        stream = new FileInputStream(fileList[i]);
462
                        stream = new FileInputStream(fileList[i]);
451
                        XmlErrorHandler handler = tldScanStream(stream);
463
                        XmlErrorHandler handler = tldScanStream(stream);
Lines 465-471 Link Here
465
                    }
477
                    }
466
                }
478
                }
467
            }
479
            }
468
        }
480
        }        
481
        if(!isFound){
482
            if (log.isDebugEnabled()) {
483
                log.debug(sm.getString("tldConfig.noTldInDir", start.getAbsolutePath()));
484
            }
485
        }        
486
        return isFound;
469
    }
487
    }
470
488
471
    /*
489
    /*
Lines 476-486 Link Here
476
     * 
494
     * 
477
     * Keep in sync with o.a.j.comiler.TldLocationsCache
495
     * Keep in sync with o.a.j.comiler.TldLocationsCache
478
     */
496
     */
479
    private void tldScanJar(JarURLConnection jarConn) {
497
    private boolean tldScanJar(JarURLConnection jarConn) {
480
498
481
        Jar jar = null;
499
        Jar jar = null;
482
        InputStream is;
500
        InputStream is;
483
        
501
        boolean isFound = false;        
484
        try {
502
        try {
485
            jar = JarFactory.newInstance(jarConn.getURL());
503
            jar = JarFactory.newInstance(jarConn.getURL());
486
            
504
            
Lines 489-494 Link Here
489
            while (entryName != null) {
507
            while (entryName != null) {
490
                if (entryName.startsWith("META-INF/") &&
508
                if (entryName.startsWith("META-INF/") &&
491
                        entryName.endsWith(".tld")) {
509
                        entryName.endsWith(".tld")) {
510
                	isFound = true;
492
                    is = null;
511
                    is = null;
493
                    try {
512
                    try {
494
                        is = jar.getEntryInputStream();
513
                        is = jar.getEntryInputStream();
Lines 507-512 Link Here
507
                jar.nextEntry();
526
                jar.nextEntry();
508
                entryName = jar.getEntryName();
527
                entryName = jar.getEntryName();
509
            }
528
            }
529
            if(!isFound){
530
                if (log.isDebugEnabled()) {
531
                    log.debug(sm.getString("tldConfig.noTldInJar",
532
                    		jarConn.getURL().getFile()));
533
                }
534
            }
510
        } catch (IOException ioe) {
535
        } catch (IOException ioe) {
511
            log.warn(sm.getString("tldConfig.jarFail", jarConn.getURL()), ioe);
536
            log.warn(sm.getString("tldConfig.jarFail", jarConn.getURL()), ioe);
512
        } finally {
537
        } finally {
Lines 514-519 Link Here
514
                jar.close();
539
                jar.close();
515
            }
540
            }
516
        }
541
        }
542
        return isFound;
517
    }
543
    }
518
544
519
545

Return to bug 56438