How to fix "JARs that were scanned but no TLDs were found in them " in Tomcat 9.0.0M10
Asked Answered
G

4

39

I'm new to Java EE and trying to work on ServletContextListener and listener job is connection to database bla bla .When I am trying to start the server (Tomcat 9) it is stuck on :

"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."

So I changed some properties in "Logging properties file" like this :

    # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.

2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.

3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.

4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

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

# To see debug messages for HTTP/2 handling, uncomment the following line:
#org.apache.coyote.http2.level = FINE

# To see debug messages for WebSocket handling, uncomment the following line:
#org.apache.tomcat.websocket.level = FINE

All answers acceptable. Thanks for all.

Geraldina answered 23/10, 2016 at 14:35 Comment(3)
Related questions: stackoverflow.com/questions/14375673 , stackoverflow.com/questions/12905001Hestia
@StephenC There is no difference between Tomcat 9 and 8?Geraldina
@StephenC Because I tried all of them but still I'm getting same result, thanks.Geraldina
B
41

This is not a bug or any kind of problem in tomcat. Tomcat is just informing you that there are jars that do not contain TLDs and you can add them to the scanner's skip list to improve startup performance. So you have two options:

  1. You can safely ignore that hint. Yet if it annoy you, you can set that specific logger to a higher logging level, and thus prevent tomcat from logging it. Just add org.apache.jasper.servlet.TldScanner.level = SEVERE to the end of logging.properties.

  2. Enable the debug logging to make tomcat list those jars and add them to the skip list. Set:

    org.apache.jasper.compiler.TldLocationsCache.level = FINE
    org.apache.jasper.servlet.TldScanner.level = FINE
    

And add the printed jars names (without the path) to tomcat.util.scan.StandardJarScanFilter.jarsToSkip=... in tomcat_dir/conf/catalina.properties

Bragg answered 23/10, 2016 at 18:6 Comment(3)
Like this :" tomcat.util.scan.StandardJarScanFilter.jarsToSkip= 1org.apache.jasper.servlet.TldScanner,2org.apache.jasper.compiler.TldLocationsCache" ?Geraldina
Sorry like this : "org.apache.jasper.compiler.TldLocationsCache.jar,org.apache.jasper.servlet.TldScanner.jar"Geraldina
No, you must list the "jars to skip", no th etomcat classes. First you need to enable the debug logging in order to find out the names of the jars, then you add them as a comma separated list to the tomcat.util.scan.StandardJarScanFilter.jarsToSkip= propertyBragg
B
15

Setting the logging to FINE, FINEST or ALL to find all jars to exclude is not neccessary.

Here is a script that finds all jars not containing TLDs (change the TOMCAT_HOME variable to match your installation) and outputs a list on the form

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

that can be pasted into catalina.properties (omit the last ',\'):

#!/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

However, if I am correctly informed, there is a possibility in tomcat 9 to exclude all jars by changing (in catalina.properties):

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\

to

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*.jar

(comment away the list on the lines below) and then override that decision for jars containg TLDs by changing:

tomcat.util.scan.StandardJarScanFilter.jarsToScan=\
log4j-web*.jar,log4j-taglib*.jar,log4javascript*.jar,slf4j-taglib*.jar

and add the list obtained by modifying the script above to list the jars that do contain TLDs:

#!/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 [ $? -eq 0 ]; then
        echo "$(basename $i),\\"
    fi
done
Basrhin answered 29/5, 2017 at 9:21 Comment(2)
Note that if any jars contain a file that contains the letters "tld" without that actually being a .tld file, those jars are also considered to contain a .tld file.Stargell
The loop body could be simplified to jar tf "${i}" | grep -iq '.tld$' && basename "${i}" while also avoiding that tld is matched anywhere else in a path.Sachasachem
M
6

change conf\context.xml file

<Context>
    <!-- only if you do not use jsp tag -->
    <JarScanner>
        <JarScanFilter defaultPluggabilityScan="false" defaultTldScan="false"/>
    </JarScanner>
</Context>

see: https://tomcat.apache.org/tomcat-9.0-doc/config/jar-scan-filter.html

Meniscus answered 3/9, 2019 at 6:10 Comment(2)
Just to add one thing: If you want to use web.xml fragments in your app (for example for a Spring Boot app deployed as a War in Tomcat), you need to put this: <JarScanFilter defaultPluggabilityScan="true" defaultTldScan="false"/>Colorfast
This is by far the cleanest, most self-contained solution, not needing any global mocking-about with catalina.properties. Any JARs that do need to be scanned however, will now have to be whitelisted. Including those in a tldScan="${tomcat.util.scan.StandardJarScanFilter.jarsToScan}, ..." attribute to the <JarScanFiter ... /> will accomplish that.Sachasachem
M
-4

same problem i was fixed.. I think this have permission problem, so need to give full access for webapps/project folder.

Massenet answered 10/7, 2018 at 10:39 Comment(1)
Please reword your question in a way that it is not guessing ("I think..."). As it stands right now this more looks like a comment.Vermicide

© 2022 - 2024 — McMap. All rights reserved.