zoukankan      html  css  js  c++  java
  • Exception starting filter encodingFilter

    1. maven运行tomcat6出现错误Exception starting filter encodingFilter:

    严重: Exception starting filter encodingFilter
    java.lang.ClassCastException: org.springframework.web.filter.CharacterEncodingFilter cannot be cast to javax.servlet.Filter
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:424)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
    at org.apache.tomcat.maven.plugin.tomcat6.AbstractRunMojo.startContainer(AbstractRunMojo.java:997)
    at org.apache.tomcat.maven.plugin.tomcat6.AbstractRunMojo.execute(AbstractRunMojo.java:512)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

      解决办法:

      将

    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>7.0</version>
    </dependency>

      修改为

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

    Scope的含义和使用

      <dependency>中<scope>,它主要管理依赖的部署。目前<scope>可以使用5个值: 
        * compile,缺省值,适用于所有阶段,会随着项目一起发布。 
        * provided,类似compile,期望JDK、容器或使用者会提供这个依赖。如servlet.jar。 
        * runtime,只在运行时使用,如JDBC驱动,适用运行和测试阶段。 
        * test,只在测试时使用,用于编译和运行测试代码。不会随项目发布。 
        * system,类似provided,需要显式提供包含依赖的jar,Maven不会在Repository中查找它。

    依赖范围(scope) 主源码classpath可用 测试源码classpath可用 会被打包
    compile 缺省值 TRUE TRUE TRUE
    test FALSE TRUE FALSE
    runtime FALSE TRUE TRUE
    provided TRUE TRUE FALSE
  • 相关阅读:
    Func<>委托、扩展方法、yield、linq ForEach综合运用
    EntityFramework学习要点记一
    MVC模型验证
    MVC过滤器
    解决EntityFramework与System.ComponentModel.DataAnnotations命名冲突
    Linq操作之Except,Distinct,Left Join 【转】
    WebClient小结
    Code First项目Migrations
    jquery之on()绑定事件和off()解除绑定事件
    Bootstrap页面响应式设计
  • 原文地址:https://www.cnblogs.com/jing99/p/7538792.html
Copyright © 2011-2022 走看看