Tomcat 7.0.25 的一个问题

鉴客 发布于 2012/01/24 10:16
阅读 2K+
收藏 0

Tomcat 前两天刚刚发布了 7.0.25 版本,不过有用户报告在使用中发现了一个问题:

当项目中不包含 WEB-INF/classes 目录时,Tomcat 7.0.25 将会报告一个错误日志,这个问题在之前的任何一个版本中都不存在,似乎问题出在下面的代码中:

 webinfClasses = context.getServletContext().getResource(
	 "/WEB-INF/classes");
 processAnnotationsUrl(webinfClasses, webXml);

and now has

 NamingEnumeration<Binding>  listBindings =
     context.getResources().listBindings("/WEB-INF/classes");
 while (listBindings.hasMoreElements()) {
     Binding binding = listBindings.nextElement();
     if (binding.getObject() instanceof FileDirContext) {
	 File webInfCLassDir =
	     new File(
		 ((FileDirContext) binding.getObject()).getDocBase());
	 processAnnotationsFile(webInfCLassDir, webXml);
     }
 }

异常信息是:
2012-01-23 09:13:01,010 ERROR [pool-8-thread-1] org.apache.catalina.startup.ContextConfig  - Unable to determine URL for WEB-INF/classes
javax.naming.NameNotFoundException: Resource /WEB-INF/classes not found
at org.apache.naming.resources.BaseDirContext.listBindings(BaseDirContext.java:733)
at org.apache.naming.resources.ProxyDirContext.listBindings

目前该 bug 已经报告出来:

https://issues.apache.org/bugzilla/show_bug.cgi?id=52511

加载中
0
红薯
红薯
的确有一些项目是没有 classes 目录的,暂时手工建一个就可以了
0
10书生
10书生
嘻嘻 总是有开发人员 不按套路出牌呀~
0
ddatsh
ddatsh

Reported: 2012-01-23 21:02 UTC by Jess Holle

Jess Holle是?

0
ddatsh
ddatsh
Konstantin Kolinko 2012-01-24 08:48:37 UTC
Several notes.

First, this exception would not happen if either of the following two is true:

1. The web.xml specifies earlier version of servlet specification than 3.0
2. The web.xml has metadata-complete="true"

Note that using metadata-complete="true" is generally recommended to speed up
web application startup. That is if you do not need features disabled by that
option. All applications in default Tomcat distributive have
metadata-complete="true".


Second, this exception is harmless.

Scanning of WEB-INF/classes is skipped, as it should be.

The exception is caught and logged. It does not impede further annotation
scanning. Execution in ContextConfig#webConfig() continues.



This issue was introduced in r1209686 > 1210 	log.error(sm.getString(
> 1211 	"contextConfig.webinfClassesUrl"), e); BTW, the exception handling was changed in r1209686 ,but the log message
template above has not been updated.
返回顶部
顶部