新从svn上检出了一个项目,配置好tomcat,启动时发现这样一条错误
validateJarFile(E:\workspace\gzmetro\webapp\WEB-INF\lib\jsp-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/jsp/JspPage.class
validateJarFile(E:\workspace\gzmetro\webapp\WEB-INF\lib\servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
validateJarFile(E:\workspace\gzmetro\webapp\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
百度一下,发现错误如下,记录一下,留作备份
tomcat的lib目录下已经有JspPage.class和Servlet.class这个类了,工程目录下的lib的的某些jar包里又有,导致加载失败。
解决方案:清楚工程lib下多余的jar包。
附:tomcat类加载顺序(引用:http://my.unix-center.net/~Zianed/?p=1026)
Tomcat下的文件目录
/bin:存放启动和关闭tomcat的脚本文件;
/conf:存放tomcat的各种配置文件,比如:server.xml
/server/lib:存放tomcat服务器所需要的各种jar文件(jar文件只可被tomcat 服务器访问)
/server/webapps:存放tomcat自带的两个web应用:admin应用和manager应用。
/common/lib:存放tomcat服务器以及所有web应用都可以访问的jar文件夹(web和tomcat服务器都可访问此jar)
/shared/lib:存放web都可访问的jar文件。(可以被所有的web访问,但不能被tomcat访问)
/logs:存放tomcat的日志文件
/webapps:当发布web应用时,默认情况下把web应用文件放于此目录下
/work:tomcat把由jsp生成的Servlet放于此目录
另:在web应用中,WEB-Inf目录下,也可以建立lib子目录,在此子目录下可以存放各种jar文件,这些jar文件只能被当前web应用访问。其中,在web-
inf目录下的lib与classes目录,Tomcat类装载器先装载classes目录下的类,再装载lib目录下的类。因为类同名时,classes优先。
其中jsp运行时,查找class的顺序为:项目文件夹(WEB-INF\lib)—>容器文件夹(tomcat\common\lib)—>jdk文件夹(jdk\jre\lib\ext)
Tomcat是一种向上寻找的层次结构,也有向下的,或者是可配置的。
Tomcat的class加载的优先顺序一览
————-
1.最先是$JAVA_HOME/jre/lib/ext/下的jar文件。
2.环境变量CLASSPATH中的jar和class文件。
3.$CATALINA_HOME/common/classes下的class文件。
4.$CATALINA_HOME/commons/endorsed下的jar文件。
5.$CATALINA_HOME/commons/i18n下的jar文件。
6.$CATALINA_HOME/common/lib 下的jar文件。(JDBC驱动之类的jar文件可以放在这里,避免配置好数据源却找不到JDBC Driver的情况。)
7.$CATALINA_HOME/server/classes下的class文件。
8.$CATALINA_HOME/server/lib/下的jar文件。
9.$CATALINA_BASE/shared/classes 下的class文件。
10.$CATALINA_BASE/shared/lib下的jar文件。
11.各自具体的webapp /WEB-INF/classes下的class文件。
12.各自具体的webapp /WEB-INF/lib下的jar文件。
class的搜寻顺序如下
————-
/WEB-INF/classes of your web application
/WEB-INF/lib/*.jar of your web application
$CATALINA_HOME/common/classes
$CATALINA_HOME/common/endorsed/*.jar
$CATALINA_HOME/common/i18n/*.jar
$CATALINA_HOME/common/lib/*.jar
$CATALINA_BASE/shared/classes
$CATALINA_BASE/shared/lib/*.jar
————–
因此放在不同webapp里的class文件,会被classloader加载成不同的实例。
在不同的webapp加载相同类名的类互不影响。
但是注意,以下包名开头的class例外:
javax.*
org.xml.sax.*
org.w3c.dom.*
org.apache.xerces.*
org.apache.xalan.*
ps,注意.在各个jar中的\META-INF\MAINFEST.MF文件里Class-Path键值对,也会提供jar的加载优先顺序。
例如某jar的MAINFEST.MF内容如下:
Manifest-Version: 1.0
Created-By: Zianed
Class-Path: commons-beanutils.jar
Class-Path: commons-collections.jar
Class-Path: commons-dbcp.jar
Class-Path: commons-digester.jar
Class-Path: commons-logging.jar
Class-Path: commons-pool.jar
Class-Path: commons-services.jar
Class-Path: commons-validator.jar
Class-Path: jakarta-oro.jar
Main-Class: Test
那么在加载这个jar的时候,会先在此jar所在目录下依次先加载commons-beanutils.jar,commons-collections.jar等jar文件。
在不同的地方放置jar和class可能会产生意想不到的后果,尤其是不同版本的jar文件,因此在实际应用部署web应用时候要特别留心.
例如 使用javamail常见的一个出错信息:
javax.mail.NoSuchProviderException: No provider for smtp
其真实原因就很可能如下:
在不同的加载jar的目录下放置了不同版本的mail.jar,比如一个是javamail1.3.1的mail.jar
在D:\jakarta-tomcat-5.5.8\common\lib下,而另外一个是javamail1.3.2的mail.jar在
D:\jakarta-tomcat-5.5.8\webapps\mialtest\WEB-INF/lib下,
那么mialtest中使用到javamail进行邮件发送的时候,便会出现No provider for smtp的错误。
分享到:
相关推荐
cannot be cast to javax.servlet.... Offending class: javax/servlet/Servlet.class 然后输出错误: 严重: Exception starting filter encodingFilter java.lang.ClassCastException: org.springframework.web.f
Offending resource: class path resource [beans.xml] at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70) 由于缺少依赖包 aspectjweaver-1.6.12...
spring4的稳定版本4.0.6 无需maven直接下载jar包 系统只允许上传50M内的文件,所以只包含了jar包
Contents Module Overview 1 Lesson 1: Memory 3 Lesson 2: I/O 73 Lesson 3: CPU 111 Module 3: Troubleshooting Server Performance ...Troubleshooting server performance-based support calls requires ...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
快取猴子 太热了。 构建设置 # install dependencies npm install # serve with hot reload at localhost:9080 npm run dev # build electron application for production ...xattr -lr ./ // fix them find
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
Offending text: iarbuild.exe $SIMPLELINK_CC13X2_26X2_SDK_INSTALL_DIR$/kernel/tirtos/builds/CC1352R1_LAUNCHXL/release/iar/tirtos_builds_CC1352R1_LAUNCHXL_release.ewp Debug -log all 使用CCS提示的...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
Troubleshooting with Wireshark: Locate the Source of Performance Problem ) By Laura Chappell Foreword by Gerald Combs Edit by Jim Aragon This book focuses on the tips and techniques used to identify ...
Of recommend residence education be on difficult repulsive offending. Judge views had mirth table seems great him for her. Alone all happy asked begin fully stand own get. Excuse ye seeing result of ...
该算法简单的实现了SVM算法的基本原理,利于读者初步理解 学习SVM算法
Process Tamer solves this problem by identifying such these degenerate conditions and temporarily reducing the priority of the offending processes in order to allow your system to respond to other ...
Sumida components are manufactured and promoted for use in general electronics devices such as audio-video equipment,home electric ...for any such problem, nor grant any license to the offending party.
often in the form of trajectories or growth curves of offending in relation to age (LeBlanc and Loeber 1998; Piquero et al. 2007). Closely tied to such studies is a sizable body of research ...
An concluded sportsman offending so provision mr education. Bed uncommonly his discovered for estimating far. Equally he minutes my hastily. Up hung mr we give rest half. Painful so he an comfort is ...
By the end of this book, you’ll know how to analyze traffic, find patterns of various offending traffic, and secure your network from them. What You Will Learn Configure Wireshark 2 for effective ...