tomcat 5.5 部署项目报错 关于Filter的错误。。

庄泽锐 发布于 2014/03/06 12:32
阅读 1K+
收藏 0

我在tomcat7.0部署没不报错,但是再tomcat5.5就会报错。。


<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <display-name></display-name>
     
     
     
<listener>
<!-- 指定Listener的实现类 -->
<listener-class>listener.ContextListener</listener-class>
</listener>


     <!-- Set URL Rewrite-->
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
</filter-class>
<init-param>  
       <param-name>logLevel</param-name>  
        <param-value>WARN</param-value>  
   </init-param>  
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
     
     
     <jsp-config>   
        <taglib>   
            <!-- 此处uri可以自己随便定义,但后面用时一定与这里一样 -->   
            <taglib-uri>   
               MyTablib    
            </taglib-uri>   
            <!-- tld文件的路径 -->   
            <taglib-location>   
               /WEB-INF/tld/custom-function.tld    
            </taglib-location>   
        </taglib>   
        
        <taglib>
      <taglib-uri>/page</taglib-uri>
      <taglib-location>/WEB-INF/tld/page.tld</taglib-location>
      </taglib>
    
    </jsp-config>
        




<filter>
  <filter-name>adminFilter</filter-name>
  <filter-class>filter.adminFilter</filter-class>
</filter>
 
<filter-mapping>
<filter-name>adminFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
<servlet-name>checkInforServlet</servlet-name>
<servlet-name>changeServlet</servlet-name>
<servlet-name>addCorpSerlvet</servlet-name>
<servlet-name>addInforSerlvet</servlet-name>
<servlet-name>changeInforSerlvet</servlet-name>
<servlet-name>checkInforServlet</servlet-name>
<servlet-name>deleteBacthInforSerlvet</servlet-name>
<servlet-name>deleteInforSerlvet</servlet-name>
<servlet-name>getInforSerlvet</servlet-name>
<servlet-name>addProduceSerlvet</servlet-name>
<servlet-name>changeProduceSerlvet</servlet-name>
<servlet-name>checkProduceServlet</servlet-name>
<servlet-name>deleteBacthProduceSerlvet</servlet-name>
<servlet-name>deleteProduceSerlvet</servlet-name>
<servlet-name>deleteTupainProduceSerlvet</servlet-name>
<servlet-name>getProduceSerlvet</servlet-name>
</filter-mapping>
 
  
  
    
  
       
  <servlet>
    <servlet-name>adminLoginServlet</servlet-name>
    <servlet-class>servlet.adminServlet.adminLoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>adminLoginServlet</servlet-name>
    <url-pattern>/adminLoginServlet</url-pattern>
  </servlet-mapping>
  
   <servlet>
    <servlet-name>changeServlet</servlet-name>
    <servlet-class>servlet.adminServlet.changeServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>changeServlet</servlet-name>
    <url-pattern>/changeServlet</url-pattern>
  </servlet-mapping>
  
  
   <servlet>
    <servlet-name>corpSerlvet</servlet-name>
    <servlet-class>servlet.corpServlet.corpSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>corpSerlvet</servlet-name>
    <url-pattern>/corpSerlvet</url-pattern>
  </servlet-mapping>
  
   <servlet>
    <servlet-name>addCorpSerlvet</servlet-name>
    <servlet-class>servlet.corpServlet.addCorpSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>addCorpSerlvet</servlet-name>
    <url-pattern>/addCorpSerlvet</url-pattern>
  </servlet-mapping>
  
   <servlet>
    <servlet-name>checkInforServlet</servlet-name>
    <servlet-class>servlet.inforServlet.checkInforServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>checkInforServlet</servlet-name>
    <url-pattern>/checkInforServlet</url-pattern>
  </servlet-mapping>
  
     <servlet>
    <servlet-name>addInforSerlvet</servlet-name>
    <servlet-class>servlet.inforServlet.addInforSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>addInforSerlvet</servlet-name>
    <url-pattern>/addInforSerlvet</url-pattern>
  </servlet-mapping>
  
     <servlet>
    <servlet-name>deleteInforSerlvet</servlet-name>
    <servlet-class>servlet.inforServlet.deleteInforSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>deleteInforSerlvet</servlet-name>
    <url-pattern>/deleteInforSerlvet</url-pattern>
  </servlet-mapping>
  
     <servlet>
    <servlet-name>getInforSerlvet</servlet-name>
    <servlet-class>servlet.inforServlet.getInforSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>getInforSerlvet</servlet-name>
    <url-pattern>/getInforSerlvet</url-pattern>
  </servlet-mapping>
  
   <servlet>
    <servlet-name>exitServlet</servlet-name>
    <servlet-class>servlet.adminServlet.exitServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>exitServlet</servlet-name>
    <url-pattern>/exitServlet</url-pattern>
  </servlet-mapping>
  
    <servlet>
    <servlet-name>changeInforSerlvet</servlet-name>
    <servlet-class>servlet.inforServlet.changeInforSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>changeInforSerlvet</servlet-name>
    <url-pattern>/changeInforSerlvet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>deleteBacthInforSerlvet</servlet-name>
    <servlet-class>servlet.inforServlet.deleteBacthInforSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>deleteBacthInforSerlvet</servlet-name>
    <url-pattern>/deleteBacthInforSerlvet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>addProduceSerlvet</servlet-name>
    <servlet-class>servlet.produceServlet.addProduceSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>addProduceSerlvet</servlet-name>
    <url-pattern>/addProduceSerlvet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>checkProduceServlet</servlet-name>
    <servlet-class>servlet.produceServlet.checkProduceServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>checkProduceServlet</servlet-name>
    <url-pattern>/checkProduceServlet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>deleteBacthProduceSerlvet</servlet-name>
    <servlet-class>servlet.produceServlet.deleteBacthProduceSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>deleteBacthProduceSerlvet</servlet-name>
    <url-pattern>/deleteBacthProduceSerlvet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>deleteProduceSerlvet</servlet-name>
    <servlet-class>servlet.produceServlet.deleteProduceSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>deleteProduceSerlvet</servlet-name>
    <url-pattern>/deleteProduceSerlvet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>getProduceSerlvet</servlet-name>
    <servlet-class>servlet.produceServlet.getProduceSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>getProduceSerlvet</servlet-name>
    <url-pattern>/getProduceSerlvet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>changeProduceSerlvet</servlet-name>
    <servlet-class>servlet.produceServlet.changeProduceSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>changeProduceSerlvet</servlet-name>
    <url-pattern>/changeProduceSerlvet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>deleteTupainProduceSerlvet</servlet-name>
    <servlet-class>servlet.produceServlet.deleteTupainProduceSerlvet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>deleteTupainProduceSerlvet</servlet-name>
    <url-pattern>/deleteTupainProduceSerlvet</url-pattern>
  </servlet-mapping>
  
   <servlet>
    <servlet-name>ToCorpHtmlServlet</servlet-name>
    <servlet-class>ToHtmlServlet.ToCorpHtmlServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>ToCorpHtmlServlet</servlet-name>
    <url-pattern>/ToCorpHtmlServlet</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>ToHomeHtmlServlet</servlet-name>
    <servlet-class>ToHtmlServlet.ToHomeHtmlServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>ToHomeHtmlServlet</servlet-name>
    <url-pattern>/ToHomeHtmlServlet</url-pattern>
  </servlet-mapping>
  
    <servlet>
    <servlet-name>ToProduceAmount</servlet-name>
    <servlet-class>ToHtmlServlet.ToProduceAmount</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>ToProduceAmount</servlet-name>
    <url-pattern>/ToProduceAmount</url-pattern>
  </servlet-mapping>
  
  <welcome-file-list>
    <welcome-file>home.html</welcome-file>
  </welcome-file-list>
  

</web-app>



java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:898)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:192)
at org.apache.tomcat.util.digester.Rule.end(Rule.java:228)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1057)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:351)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1041)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:260)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4143)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Caused by: java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>
at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2107)
... 46 more
2014-3-6 12:12:31 org.apache.catalina.startup.ContextConfig applicationWebConfig
严重: Parse error in application web.xml file at jndi:/localhost/WEB-INF/web.xml
java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2725)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2751)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1060)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:351)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1041)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:260)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4143)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)



加载中
0
Brin想写程序
Brin想写程序

tomcat 5.5不支持 Servlet2.5

你的web.xml的写法是Servlet 2.5的。

注意看你的文件头部:

<web-app version="2.5"  
xmlns="http://java.sun.com/xml/ns/javaee"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 


在2.5版本的xsd里面:

 <xsd:sequence>
      <xsd:element name="filter-name"
  type="javaee:filter-nameType"/>
      <xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="url-pattern"
    type="javaee:url-patternType"/>
<xsd:element name="servlet-name"
    type="javaee:servlet-nameType"/>
      </xsd:choice>
      <xsd:element name="dispatcher"
  type="javaee:dispatcherType"
  minOccurs="0" maxOccurs="4"/>
    </xsd:sequence>

是这样的

而在2.4版本:

是这个:

  <xsd:complexType name="filter-mappingType">
    <xsd:annotation>
      <xsd:documentation>

 Declaration of the filter mappings in this web
 application is done by using filter-mappingType.
 The container uses the filter-mapping
 declarations to decide which filters to apply to a request,
 and in what order. The container matches the request URI to
 a Servlet in the normal way. To determine which filters to
 apply it matches filter-mapping declarations either on
 servlet-name, or on url-pattern for each filter-mapping
 element, depending on which style is used. The order in
 which filters are invoked is the order in which
 filter-mapping declarations that match a request URI for a
 servlet appear in the list of filter-mapping elements.The
 filter-name value must be the value of the filter-name
 sub-elements of one of the filter declarations in the
 deployment descriptor.

      </xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>
      <xsd:element name="filter-name"
     type="j2ee:filter-nameType"/>
      <xsd:choice>
 <xsd:element name="url-pattern"
       type="j2ee:url-patternType"/>
 <xsd:element name="servlet-name"
       type="j2ee:servlet-nameType"/>
      </xsd:choice>
      <xsd:element name="dispatcher"
     type="j2ee:dispatcherType"
     minOccurs="0" maxOccurs="4"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID"/>
  </xsd:complexType>

区别在于  <xsd:choice>和 <xsd:choice minOccurs="1" maxOccurs="unbounded">
0
顺其自然001
顺其自然001
严重: Parse error in application web.xml file at jndi:/localhost/WEB-INF/web.xml
java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>
0
顺其自然001
顺其自然001

either a <url-pattern> or a <servlet-name>

就是要么 用 <url-pattern>  ,要么 <servlet-name>,不能两个都放里面。

应该是 adminFilter 这个


0
_金角大王_
_金角大王_
下次请用代码格式 -,- !!
0
水手居士
水手居士

引用来自“然则何时而乐”的答案

either a <url-pattern> or a <servlet-name>

就是要么 用 <url-pattern>  ,要么 <servlet-name>,不能两个都放里面。

应该是 adminFilter 这个


  <xsd:complexType name="filter-mappingType">
    <xsd:annotation>
      <xsd:documentation>


Declaration of the filter mappings in this web
application is done by using filter-mappingType.
The container uses the filter-mapping
declarations to decide which filters to apply to a request,
and in what order. The container matches the request URI to
a Servlet in the normal way. To determine which filters to
apply it matches filter-mapping declarations either on
servlet-name, or on url-pattern for each filter-mapping
element, depending on which style is used. The order in
which filters are invoked is the order in which
filter-mapping declarations that match a request URI for a
servlet appear in the list of filter-mapping elements.The
filter-name value must be the value of the filter-name
sub-elements of one of the filter declarations in the
deployment descriptor.


      </xsd:documentation>

    </xsd:annotation>

特意查了一下,确实是这个原因~

返回顶部
顶部