当前位置: 代码迷 >> J2EE >> 在启动TOMCAT时出现java.lang.ClassCastException: org.apache.naming.resources.FileDirContext异常
  详细解决方案

在启动TOMCAT时出现java.lang.ClassCastException: org.apache.naming.resources.FileDirContext异常

热度:336   发布时间:2016-04-22 02:52:30.0
在启动TOMCAT时出现java.lang.ClassCastException: org.apache.naming.resources.FileDirContext错误
错误的提示内容如下;严重:   Error   deploying   web   application   directory   test(test   是我的项目名)
java.lang.ClassCastException:   org.apache.naming.resources.FileDirContext
at   org.apache.catalina.util.ExtensionValidator.validateApplication(ExtensionValidator.java:182)
at   org.apache.catalina.core.StandardContext.start(StandardContext.java:4153)
at   org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
at   org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
at   org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at   org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at   org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at   org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at   org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at   org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at   org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at   org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)
at   org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at   org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)
at   org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at   org.apache.catalina.core.StandardService.start(StandardService.java:448)
at   org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at   org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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:585)
at   org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at   org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2007-4-3   12:22:07   org.apache.coyote.http11.Http11Protocol   start
信息:   Starting   Coyote   HTTP/1.1   on   http-8080
2007-4-3   12:22:07   org.apache.jk.common.ChannelSocket   init
信息:   JK:   ajp13   listening   on   /0.0.0.0:8009
2007-4-3   12:22:07   org.apache.jk.server.JkMain   start
信息:   Jk   running   ID=0   time=0/160     config=null
2007-4-3   12:22:08   org.apache.catalina.startup.Catalina   start
信息:   Server   startup   in   20479   ms

请各位高手出手相助,我被困住了几天了。


------解决方案--------------------
java.lang.ClassCastException: org.apache.naming.resources.FileDirContext
at org.apache.catalina.util.ExtensionValidator.validateApplication(ExtensionValidator.java:182)


看你ExtensionValidator.java的182行。
类型强制转换错误了。

------解决方案--------------------
java.lang.ClassCastException: org.apache.naming.resources.FileDirContext
at org.apache.catalina.util.ExtensionValidator.validateApplication(ExtensionValidator.java:182)

---------------------
类型转换错误,楼主要注意你的WEB应用用的CLASSLOADER和你业务层用的可能不是同一个CLASSLOADER, 也即是说你转换的类型即使一样但它们位于不同的命名空间也会抛出这个错误.
------解决方案--------------------
  相关解决方案