tomcat启动时候报错java.lang.ClassCastException
Posted tfy1332
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat启动时候报错java.lang.ClassCastException相关的知识,希望对你有一定的参考价值。
2012-8-29 10:30:28 org.apache.catalina.core.StandardContext filterStart
严重: 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:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4038)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4692)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
10:30:28,307 DEBUG StandardServletEnvironment:104 - Adding [systemEnvironment] PropertySource with lowest search precedence
10:30:28,307 DEBUG StandardServletEnvironment:120 - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,jndiProperties,systemProperties,systemEnvironment]
10:30:28,338 DEBUG StandardServletEnvironment:114 - Initializing new StandardServletEnvironment
10:30:28,338 DEBUG StandardServletEnvironment:104 - Adding [servletConfigInitParams] PropertySource with lowest search precedence
10:30:28,338 DEBUG StandardServletEnvironment:104 - Adding [servletContextInitParams] PropertySource with lowest search precedence
10:30:28,354 DEBUG StandardServletEnvironment:104 - Adding [jndiProperties] PropertySource with lowest search precedence
10:30:28,354 DEBUG StandardServletEnvironment:104 - Adding [systemProperties] PropertySource with lowest search precedence
10:30:28,354 DEBUG StandardServletEnvironment:104 - Adding [systemEnvironment] PropertySource with lowest search precedence
10:30:28,354 DEBUG StandardServletEnvironment:120 - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,jndiProperties,systemProperties,systemEnvironment]
2012-8-29 10:30:28 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter hibernateOpenSessionInViewFilter
java.lang.ClassCastException: org.springframework.orm.hibernate4.support.OpenSessionInViewFilter 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:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4038)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4692)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2012-8-29 10:30:28 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2012-8-29 10:30:28 org.apache.catalina.core.StandardContext start
严重: Context [/auditapp] startup failed due to previous errors
2012-8-29 10:30:28 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/auditapp] registered the JDBC driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
------Solutions------
目测是因为楼主的spring encodingFilter 配置有问题。
<filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
------Solutions------
应该是jar包冲突了 检查下程序下的lib包的jar和tomcat自己目录下是否有重复的jar包,删除掉一个低版本的就可以了
以上是关于tomcat启动时候报错java.lang.ClassCastException的主要内容,如果未能解决你的问题,请参考以下文章
tomcat启动时候报错java.lang.ClassCastException