Tomcat 8 enable debug logging to list unneeded jars
Asked Answered
H

4

14

When starting Tomcat 8 on Arch Linux ARM I get the following warning:

INFO: 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.`

I already modified ${catalina.home}/logging.properties like described here: How to fix JSP compiler warning: one JAR was scanned for TLDs yet contained no TLDs?

I changed some logging levels from INFO to FINE, uncommented "org.apache.jasper.compiler.TldLocationsCache.level = FINE" and added "org.apache.jasper.servlet.TldScanner.level = FINE". So the end of the file now looks the following:

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = FINE org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = FINE org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = FINE org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log # each component that extends LifecycleBase changing state: #org.apache.catalina.util.LifecycleBase.level = FINE

# To see debug messages in TldLocationsCache, uncomment the following line: org.apache.jasper.compiler.TldLocationsCache.level = FINE org.apache.jasper.servlet.TldScanner.level = FINE

But I still get the warning at startup and not the unneeded JAR's paths. What's wrong?

Hartz answered 18/7, 2014 at 9:40 Comment(3)
#12905501Predecease
possible duplicate of Tomcat 7 JSP compiler emits "unneeded JAR" warningSubcommittee
I don't think this is a duplicate question. None of the links in the previous comments address the issue. I am also experiencing this problem where the message is still displayed even though I have set my logging.properties to produce a list of JARs.Margalit
M
9

Try debugging for everything by:

  1. Adding this to the end of your logging.properties file located in {CATALINA-HOME}/conf:

    #To see the most detailed level of logging for all classes, uncomment the following line:
    org.apache.catalina.level=FINEST
    
  2. Restart Tomcat

  3. Run the following from Terminal to get a list of jars that need to be skipped (courtesy of @joseph-lust on this post):

    egrep "No TLD files were found in \[file:[^\]+\]" {CATALINA-HOME}/logs/catalina.out -o | egrep "[^]/]+.jar" -o | sort | uniq | sed -e 's/.jar/.jar,\\/g' > ~/skips.txt
    
  4. Open skips.txt in your user home directory

  5. Add this list to {CATALINA-HOME}/conf/catalina.properties after the following line:

    org.apache.catalina.startup.TldConfig.jarsToSkip=
    
  6. Make sure to remove/comment out this when you are done to prevent your log files from growing too large

I am still not sure why this happens, as it seems to work for most to uncomment the TldLocationsCache line.

Margalit answered 8/9, 2015 at 10:55 Comment(0)
S
5

An easier way, in step 1 of the above post, instead of enabling debugging for everything, limit to org.apache.jasper:

Use this:

org.apache.jasper.level = FINEST

Instead of this:

org.apache.catalina.level=FINEST
Sealer answered 31/3, 2017 at 21:43 Comment(1)
This should be a comment on the original answerHetaera
F
2

I wrote a script to find all jars that don't contain a TLD:

#!/bin/sh
TOMCAT_HOME=/opt/tomcat
for i in `find $TOMCAT_HOME -follow -name "*jar"`
do
    jar tvf $i | grep -i tld > /dev/null
    if [ $? -ne 0 ]; then
        echo "$(basename $i),\\"
    fi
done

Edit the TOMCAT_HOME to match your installation, The script produces a list on the form:

jar1.jar,\
jar2.jar,\
...

that may be pasted into catalina.properties at:

org.apache.catalina.startup.TldConfig.jarsToSkip=
Feliciafeliciano answered 29/5, 2017 at 16:5 Comment(0)
M
1

The org.apache.jasper.servlet.TldScanner.level = FINE line mentioned in the original question should be enough to get the unneeded JARs' paths. Presumably, something else is preventing the logging from working.

If you are using Eclipse and are running Tomcat as a Server on the Servers tab, there might be some extra configuration needed to properly read logging.properties.

  1. Open the Servers tab if it is not already open (Window > Show View > Other... > Server > Servers). Stop the Tomcat server if it is running.
  2. In the Servers tab, double-click the Tomcat server for which logging settings should be adjusted. This should open the Overview tab for the server.
  3. Under the "General Information" section, click "Open launch configuration". This should bring up the Edit Configuration popup.
  4. Switch to the Arguments tab. In the VM arguments section, append the following arguments, adjusting the first argument to the path of your logging.properties file:
    • -Djava.util.logging.config.file="C:\REPLACE\WITH\PATH\TO\TOMCAT\conf\logging.properties"
    • -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  5. Start Tomcat and look for lines like the following in the console:
01-Dec-2020 20:18:32.069 FINE [main] org.apache.jasper.servlet.TldScanner$TldScannerCallback.scan No TLD files were found in [file:/C:/projects/so/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/webapps/so_proj/WEB-INF/lib/gson-2.8.1.jar]. Consider adding the JAR to the tomcat.util.scan.StandardJarScanFilter.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.

Credit to Steve Mitchell's answer here which helped me out.

Mew answered 2/12, 2020 at 0:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.