在tomcat

时间:2015-08-24 10:38:37

标签: java eclipse spring-mvc tomcat

这是我的webapp的过滤器类。

package com.altimetrik.aep.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class CrossScriptingFilter implements Filter {
    private FilterConfig filterConfig;

    public void init(FilterConfig filterConfig) throws ServletException {
        this.filterConfig = filterConfig;
    }

    public void destroy() {
        this.filterConfig = null;
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
        chain.doFilter(new RequestWrapper((HttpServletRequest) request), response);
    }

}

在Tomcat中部署应用程序时出现以下错误。

INFO: No Spring WebApplicationInitializer types detected on classpath
Aug 24, 2015 3:39:48 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter xss
java.lang.ClassNotFoundException: com.altimetrik.aep.filter.CrossScriptingFilter
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:252)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4584)
    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5262)
    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5257)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

Aug 24, 2015 3:39:48 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Aug 24, 2015 3:39:48 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/ca] startup failed due to previous errors
Aug 24, 2015 3:39:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Aug 24, 2015 3:39:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Aug 24, 2015 3:39:48 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 9014 ms

请帮助解决此错误。当我将war文件放在webapps文件夹中并启动tomcat时,我能够部署它。但无法通过eclipse或STS中的tomcat服务器部署它。

请找我的web.xml。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Continuous-Assessment-Service</display-name>

    <!-- 
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>ca-dao.xml </param-value>
    </context-param>
    <listener>
         <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class>
    </listener> -->


 <servlet>
      <servlet-name>continuousAssessment</servlet-name>
      <servlet-class>
         org.springframework.web.servlet.DispatcherServlet
      </servlet-class>

      <load-on-startup>1</load-on-startup>
   </servlet>

   <servlet-mapping>
      <servlet-name>continuousAssessment</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping> 


     <filter>
        <filter-name>xss</filter-name>
        <filter-class>com.altimetrik.aep.filter.CrossScriptingFilter</filter-class>
     </filter>

     <filter-mapping>
                <filter-name>xss</filter-name>
                <url-pattern>/*</url-pattern>
     </filter-mapping>



    <welcome-file-list>
        <welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>
    </welcome-file-list> 
</web-app>

0 个答案:

没有答案