TOMCAT中JSP文件不可获取原因分析

附件
22.jpg(21.3 K)
 
切换到幻灯片模式

由于TOMCAT更新速度很快,因此,我们有很多人今天下了这个版本,明天下了那个版本,不同版本需要搭配不同的JDK,于是,我们将从网上下载的许多WEB-APP拷贝到自己的容器时,就会出现这样那样的问题。最终分析来分析去发现是web.xml这个文件是最终导致TOMCAT经常出错的原因。

一、出错:
从网络上下载了cewolf的一个例子,当拷贝TOMCAT相关位置后,发现居然无法访问,提示如下:
1
2
3
4
5
6
7
HTTP Status 404 - /cewolf/CewolfVBar.jsp
 
type Status report
message /cewolf/CewolfVBar.jsp
description The requested resource (/cewolf/CewolfVBar.jsp) is not available.
 
Apache Tomcat/5.5.17

首先,已经确定URL路径是正确的:http://localhost:8080/cewolf/CewolfVBar.jsp
其次,主页访问没有问题,自带的其他WEB-APP也没有问题。

二、分析:
来看一下TOMCAT的logs(c:\tomcat5\logs)
关闭tomcat服务,将logs目录下的所有日志文件清除,然后重新启动程序。分析以下日志文件:
catalina.2006-11-17.log
------------------------------------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2006-11-17 13:23:38 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Apache Software Foundation\Tomcat 5.5\bin;.;C:\WINDOWS\system32;C:\WINDOWS;c:\ruby\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;e:\masm32\bin;C:\MySQL\MySQL Server 5.0\bin;C:\Program Files\DeskAdTop
2006-11-17 13:23:39 org.apache.coyote.http11.Http11BaseProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2006-11-17 13:23:39 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1893 ms
2006-11-17 13:23:39 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2006-11-17 13:23:39 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.17
2006-11-17 13:23:39 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2006-11-17 13:23:42 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\cewolf\WEB-INF\lib\servlet-api-2.3.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2006-11-17 13:23:42 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2006-11-17 13:23:42 org.apache.catalina.core.StandardContext start
严重: Context [/cewolf] startup failed due to previous errors
2006-11-17 13:23:43 org.apache.coyote.http11.Http11BaseProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2006-11-17 13:23:43 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2006-11-17 13:23:43 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/60  config=null
2006-11-17 13:23:43 org.apache.catalina.storeconfig.StoreLoader load
信息: Find registry server-registry.xml at classpath resource
2006-11-17 13:23:43 org.apache.catalina.startup.Catalina start
信息: Server startup in 4817 ms

服务器在加载webapp时出现错误,而且这个错误的出现导致了StandardContext Listener的正常启动。因此/cewolf加载失败:“严重: Context [/cewolf] startup failed due to previous errors”, 其实,只看这个提示是无法正确找到原因的,由于TOMCAT自带的WEB-APP能够正常运行,因此开始了对比测试。经测试,发现web.xml是导致出现这个问题的罪魁祸首。
那么,先来看看到底原来的web.xml是个什么样子的:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
  Copyright 2004 The Apache Software Foundation
 
  Licensed 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.
-->
 
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
 
    <description>
      JSP 2.0 Examples.
    </description>
    <display-name>JSP 2.0 Examples</display-name>
 
 
    <!-- Define servlet-mapped and path-mapped example filters -->
    <filter>
        <filter-name>Servlet Mapped Filter</filter-name>
        <filter-class>filters.ExampleFilter</filter-class>
	<init-param>
	    <param-name>attribute</param-name>
	    <param-value>filters.ExampleFilter.SERVLET_MAPPED</param-value>
	</init-param>
    </filter>
    <filter>
        <filter-name>Path Mapped Filter</filter-name>
        <filter-class>filters.ExampleFilter</filter-class>
	<init-param>
	    <param-name>attribute</param-name>
	    <param-value>filters.ExampleFilter.PATH_MAPPED</param-value>
	</init-param>
    </filter>
 
<!-- Example filter mapping to apply the "Set Character Encoding" filter
     to *all* requests processed by this web application -->
<!--
    <filter-mapping>
        <filter-name>Set Character Encoding</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
-->

<!--
    <filter-mapping>
      <filter-name>Compression Filter</filter-name>
      <url-pattern>/CompressionTest</url-pattern>
    </filter-mapping>
-->

<!--
    <filter-mapping>
        <filter-name>Request Dumper Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
-->

    <!-- Define example application events listeners -->
    <listener>
        <listener-class>listeners.ContextListener</listener-class>
    </listener>
    <listener>
        <listener-class>listeners.SessionListener</listener-class>
    </listener>

    <!-- Define servlets that are included in the example application -->

    <servlet>
      <servlet-name>
          servletToJsp
      </servlet-name>
      <servlet-class>
          servletToJsp
      </servlet-class>
    </servlet>
……


三、解决
如果你不确定web.xml中到底哪个地方出现问题,建议你使用tomcat中的web-app下的tomcat-docs程序中的web.xml,这个描述文件最简单,没有定义多余的东西,当然,有必要根据你的应用程序进行修改,以下是修改以后的web.mxl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
 
  <display-name>Tomcat Documentation</display-name>
  <description>
     Tomcat Documentation.
  </description>
 
<servlet>
  <servlet-name>CewolfServlet</servlet-name>
  <servlet-class>de.laures.cewolf.CewolfRenderer</servlet-class>
 
  <init-param>
<param-name>overliburl</param-name>
<param-value>overlib.js</param-value>
  </init-param>
 
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>CewolfServlet</servlet-name>
  <url-pattern>/cewolf/*</url-pattern>
</servlet-mapping>
</web-app>



平均得分
(0 次评分)





文章来自: 本站原创
标签:
评论: 18 | 查看次数: 32901
  • 共有 18 条评论
  • 1
  • 2
  • |
  • >>
游客 [2008-11-20 13:33:46]
游客 [2008-11-18 19:55:08]
游客 [2008-11-12 09:30:09]
游客 [2008-11-05 15:21:22]
游客 [2008-10-31 14:26:41]
游客 [2008-10-24 14:55:37]
游客 [2008-10-20 15:47:17]
游客 [2008-09-28 15:26:36]
游客 [2008-09-16 16:13:06]
游客 [2008-08-07 15:23:14]
游客 [2008-08-07 13:53:45]
游客 [2008-08-05 11:21:38]
游客 [2008-08-01 11:30:45]
游客 [2008-07-25 10:46:45]
精油
论文发表
上海翻译公司
上海翻译
英语培训
英语口语
神经性皮炎
皮炎
湿疹
荨麻疹
慢性荨麻疹
藏獒
液压缸
油缸
破碎机
北京旅游
北京旅行社
条码机
条码打印机
条形码打印机
阴茎增大
伟哥
发酵罐
肠炎
结肠炎
直肠炎
慢性肠炎
慢性结肠炎
结肠炎的治疗
溃疡性结肠炎
慢性结肠炎的治疗
大豆床上用品
保健内衣
羊绒内衣
大豆纤维面料
团购礼品
移民
热电偶插头
测温线
热电阻
煤气发生炉
两段式煤气发生炉
环保节能型煤气发生炉
硅碳棒
吸塑机
纸管机
无缝管
合金管
无缝管
无缝钢管
高血压
产品设计
无纸记录仪
红外测温仪
无纸记录仪
韩国服装
韩版服装
韩国服饰
丝锥
挤压丝锥
非标丝锥
梯形丝锥
螺纹环规
节能胶带机
胶带机价格
太阳能
太阳能热水器
分体式太阳能
二手车
北京二手车
北京二手车交易
北京二手汽车
二手车汽车
山特ups电源
山特ups
山特ups报价
ups电源
ups
全自动表面张力仪/界面张力仪
inflatable
bouncer
men spa beijing
men massage beijing
pearl jewelry
Beijing Tour
china Tour
beijing Tour
china Tour
beijing Tour
China Necklace Wholesale
China Bracelet Wholesale
China Ring wholesale
China gemstone beads wholesale
China Jewelry Accessories wholesale
China Semiprecious beads wholesale
replica handbag
replica tiffany
replica watches
louis vuitton replica
chanel replica
gucci replica
Chinese language
Chinese learn
learning Chinese
learn mandarin
ecosway
gasifier
coal gas
coal gasification
pro dj cases
beijing tour
beijing tours
beijing travel
beijing tours
china tour
beijing
china tours
china travel
beijing china
china beijing
beijing hotel
beijing hotels
China Flights
carved fireplace
stone bathtub
marble fountain
marble bench
marble fireplace
marble sculpture
marble columns
marble lions
marble doorway
marble gazebo
marble pillar
marble fireplace surround
marble statue
marble bathtub
游客 [2008-07-15 12:00:03]
  • 共有 18 条评论
  • 1
  • 2
  • |
  • >>
发表评论
昵 称:  登录
内 容:
选 项:
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启