问题描述
- java.lang.ClassNotFoundException异常有哪些可能
-
新手一枚,写了个Struts2的demo,导入Struts2.3.4的jar包,用MyEclipse10自带的tomcat跑然后报错严重: Exception starting filter struts2base01
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExcuteFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:249)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4340)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
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:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
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:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2016-5-6 16:08:43 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2016-5-6 16:08:43 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2_base01] startup failed due to previous errors
解决方案
重新编译下 或者所有JAR包重新导入试下
解决方案二:
唯一的可能就是你少了jar包
解决方案三:
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExcuteFilter他提示了这个错误,有几种可能,一种是少包,一种是多包,你去搜一下需要哪些包,再看看包的版本是否合适
解决方案四:
问题详情:java.lang.ClassNotFoundException: freemarker.template.TemplateHashModelEx
今天为了使用freemarker模板,想整合到springMVC中,但是这个异常困扰了我好长时间。还是有必要写一篇文章来记录一下这个辛酸的过程了。
其实出现找不到类的异常,一般情况下都是找不到jar包。很自然的会去查看freemarker......
答案就在这里:关于java.lang.ClassNotFoundException异常
解决方案五:
类没找到,可能是jar包确实,也有尽可能使你的jar包添加待lib下之后没有创建路径
解决方案六:
两种情况:一种是缺少类或者jar包;一种就是编译器有问题:你使用maven重新更新一遍试试看(快捷键ctrl+f5)