简体   繁体   中英

How to diagnose the “Error listenerStart” error during WAR deploy in Tomcat7?

When I deploy my war file my-server.war to Tomcat7 (using mvn cargo:deploy or mvn cargo:redeploy ), I get the errors Error listenerStart and Context [/my-server] startup failed due to previous errors (see log fragment see below).

Jul 12, 2013 12:52:41 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/my-server.war
Jul 12, 2013 12:52:42 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jul 12, 2013 12:52:42 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/my-server] startup failed due to previous errors
Jul 12, 2013 12:53:13 PM org.apache.catalina.session.ManagerBase processExpires
FINE: Start expire sessions StandardManager at 1373633593504 sessioncount 0
Jul 12, 2013 12:53:13 PM org.apache.catalina.session.ManagerBase processExpires
FINE: End expire sessions StandardManager processingTime 1 expired sessions: 0
Jul 12, 2013 12:53:33 PM org.apache.jasper.compiler.TldLocationsCache tldScanJar
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.
Jul 12, 2013 12:54:13 PM org.apache.catalina.session.ManagerBase processExpires
FINE: Start expire sessions StandardManager at 1373633653518 sessioncount 0
Jul 12, 2013 12:54:13 PM org.apache.catalina.session.ManagerBase processExpires
FINE: End expire sessions StandardManager processingTime 21 expired sessions: 0

In order to diagnose this error, I want to configure the Tomcat logging so that the stack trace is displayed in the log file.

I changed the log4j.properties and logging.properties as shown below, but I still can't see the stack trace.

What part of which logging configuration file should I change in order for the details of both errors ( Error listenerStart and Context [/my-server] startup failed due to previous errors ) to be present in the log files?

log4j.properties:

log4j.rootLogger=debug, R 
log4j.appender.R=org.apache.log4j.RollingFileAppender 
log4j.appender.R.File=${catalina.home}/logs/tomcat.log 
log4j.appender.R.MaxFileSize=10MB 
log4j.appender.R.MaxBackupIndex=10 
log4j.appender.R.layout=org.apache.log4j.PatternLayout 
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n 
log4j.logger.org.apache.catalina=DEBUG, R
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG, R
log4j.logger.org.apache.catalina.core=DEBUG, R
log4j.logger.org.apache.catalina.session=DEBUG, R

logging.properties:

# 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.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

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

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

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

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

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

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

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter


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

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = DEBUG
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler

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

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

# 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

I found out that this strange behaviour was caused by the line marked below.

<bean id="SomeService" class="com.mycompany.SomeService">
    <property name="persistence" ref="persistence" /> <!-- This line causes the deployment problems -->
</bean>

After I made sure that the values of name and ref are different, I could successfully deploy my WAR file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM