Severity: Exception Starting filter Encodingfilter
Java.lang.ClassCastException:org.springframework.web.filter.CharacterEncodingFilter cannot is cast to Javax.servlet.Filter
At Org.apache.catalina.core.ApplicationFilterConfig.getFilter (applicationfilterconfig.java:275)
At Org.apache.catalina.core.ApplicationFilterConfig.setFilterDef (applicationfilterconfig.java:422)
At Org.apache.catalina.core.applicationfilterconfig.<init> (applicationfilterconfig.java:115)
At Org.apache.catalina.core.StandardContext.filterStart (standardcontext.java:4001)
At Org.apache.catalina.core.StandardContext.start (standardcontext.java:4651)
At Org.apache.catalina.core.ContainerBase.start (containerbase.java:1045)
At Org.apache.catalina.core.StandardHost.start (standardhost.java:785)
At Org.apache.catalina.core.ContainerBase.start (containerbase.java:1045)
At Org.apache.catalina.core.StandardEngine.start (standardengine.java:445)
At Org.apache.catalina.startup.Embedded.start (embedded.java:825)
At Org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer (abstractrunmojo.java:558)
At Org.codehaus.mojo.tomcat.AbstractRunMojo.execute (abstractrunmojo.java:255)
At Org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (defaultbuildpluginmanager.java:133)
At Org.apache.maven.lifecycle.internal.MojoExecutor.execute (mojoexecutor.java:208)
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:108)
At Org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (lifecyclemodulebuilder.java:76)
At Org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build ( SINGLETHREADEDBUILDER.JAVA:51)
At Org.apache.maven.lifecycle.internal.LifecycleStarter.execute (lifecyclestarter.java:116)
At Org.apache.maven.DefaultMaven.doExecute (defaultmaven.java:361)
At Org.apache.maven.DefaultMaven.execute (defaultmaven.java:155)
At Org.apache.maven.cli.MavenCli.execute (mavencli.java:584)
At Org.apache.maven.cli.MavenCli.doMain (mavencli.java:213)
At Org.apache.maven.cli.MavenCli.main (mavencli.java:157)
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:497)
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)
Scene: In the Spring+springmvc+mybatis integration problem, there is a package of conflict, right, is the package of conflict, cast is added meaning, This is to say that org.springframework.web.filter.CharacterEncodingFilter can not be compatible with Javax.servlet.Filter, they implement the same functions, put together there is a conflict.
Solution: It took three days to think about this question, the answer that was found on the Internet is also explained, all said to add
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
But when he joined, it did not solve the problem, then doubted whether the problem was here. Faced with a pile of ignorant English, the whole person is confused. Since the project is imported from the outside, always suspect that the project is a problem, so try to import other SSM project, try to re-write the new project code, try to use Eclipse and myeclipse two tools comparison test ... Try a lot of scenarios, and ultimately it won't solve the problem. Back, and then look at the packet conflict problem, to find out where the two packages, and finally found that the spring package and Java EE package inside the problem, tried to delete Java EE inside filter, but there are new problems arise. In the thinking of how to shield the filter in Java EE, finally try to look at the above <scope>, and try to use in the Java EE configuration, finally passed. Here is an online explanation of the <scope> pair:
So the problem is solved.
Summary, encounter problems, must be calm, analysis of the problem in the end where, do not fear the problem, the fear of the problem will only let themselves deviate from the right path, so that the time to solve the problem becomes longer. Identify a problem, no matter how difficult, will be able to find solutions, as long as they know what their problems are
Java.lang.ClassCastException:org.springframework.web.filter.CharacterEncodingFilter cannot be cast