1

当我将我的 war 文件部署my-server.war到 Tomcat7(使用mvn cargo:deployor mvn cargo:redeploy)时,我得到了错误Error listenerStartContext [/my-server] startup failed due to previous errors(见下面的日志片段)。

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

为了诊断此错误,我想配置 Tomcat 日志记录,以便在日志文件中显示堆栈跟踪。

我更改了log4j.propertiesandlogging.properties如下所示,但我仍然看不到堆栈跟踪。

我应该更改哪个日志记录配置文件的哪个部分,以便在日志文件中显示两个错误 (Error listenerStartContext [/my-server] startup failed due to previous errors) 的详细信息?

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

日志记录属性:

# 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
4

1 回答 1

2

我发现这种奇怪的行为是由下面标记的行引起的。

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

在确定 和 的值name不同ref后,我可以成功部署我的 WAR 文件。

于 2013-07-14T16:41:06.140 回答