java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
2016-10-11 11:59
417 查看
转载连接
在web.xml中配置了spring的上下文监听器:
eclipse中web项目部署到tomcat时出现的错误
Xml代码
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
随后启动tomcat服务器,控制台提示如下错误:
Java代码
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
这种错误意思很明确:找不到“ org.springframework.web.context.ContextLoaderListener”这个类,ContextLoaderListener这个类是在spring-web.jar包下,我仔细检查了项目jar环境,发现该jar包确实存在,而且也能找到编译后的ContextLoaderListener.class文件。
Java代码
Java虚拟机是根据Java ClassLoader(类加载器)决定如何加载Class。
系统默认提供了3个ClassLoader
Root ClassLoader,ClassPath Loader,Ext ClassLoader
我们也可以编写自己的ClassLoader,去加载特定环境下的Jar文件。
能不能加载Jar,加载哪里的Jar,是由ClassLoader决定的。
楼主的问题可能是 导入的仅仅是jar包的引用,例如在eclipse中通过build path加进user lib……(类似快捷方式)
这种在Java Application中没问题,但在web Application中可能会出现找不到类的异常。
在WEB Application中jar包最好放在webroot或webcontent下的lib文件夹内,特别是xml中用到的jar包。
因为我是通过eclipse的build path直接引用的jar包,没有把jar文件拷贝到lib目录下。
将所需的jar包全部拷贝到WEB-INF/lib下,再重新启动tomcat便能顺利通过了。
在web.xml中配置了spring的上下文监听器:
eclipse中web项目部署到tomcat时出现的错误
Xml代码
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
随后启动tomcat服务器,控制台提示如下错误:
Java代码
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
这种错误意思很明确:找不到“ org.springframework.web.context.ContextLoaderListener”这个类,ContextLoaderListener这个类是在spring-web.jar包下,我仔细检查了项目jar环境,发现该jar包确实存在,而且也能找到编译后的ContextLoaderListener.class文件。
Java代码
Java虚拟机是根据Java ClassLoader(类加载器)决定如何加载Class。
系统默认提供了3个ClassLoader
Root ClassLoader,ClassPath Loader,Ext ClassLoader
我们也可以编写自己的ClassLoader,去加载特定环境下的Jar文件。
能不能加载Jar,加载哪里的Jar,是由ClassLoader决定的。
楼主的问题可能是 导入的仅仅是jar包的引用,例如在eclipse中通过build path加进user lib……(类似快捷方式)
这种在Java Application中没问题,但在web Application中可能会出现找不到类的异常。
在WEB Application中jar包最好放在webroot或webcontent下的lib文件夹内,特别是xml中用到的jar包。
因为我是通过eclipse的build path直接引用的jar包,没有把jar文件拷贝到lib目录下。
将所需的jar包全部拷贝到WEB-INF/lib下,再重新启动tomcat便能顺利通过了。
相关文章推荐
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 问题原因。
- 关于java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- Tomcat 启动报java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 异常
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- 【java】—— 真正解决java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- SSH框架问题——java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener报错
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven 报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener