今天学习spring+cxf的时候遇到一个问题:在web.xml中配置了spring的上下文监听器:

  1. <listener>
  2. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  3. </listener>

随后启动tomcat服务器,控制台提示如下错误:

  1. java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

这种错误意思很明确:找不到“ org.springframework.web.context.ContextLoaderListener”这个类,ContextLoaderListener这个类是在spring-web.jar包下,我仔细检查了项目jar环境,发现该jar包确实存在,而且也能找到编译后的ContextLoaderListener.class文件。

当时很疑惑,随后去网上找答案,终于发现问题根源:

  1. Java虚拟机是根据Java ClassLoader(类加载器)决定如何加载Class。
  2. 系统默认提供了3个ClassLoader
  3. Root ClassLoader,ClassPath Loader,Ext ClassLoader
  4. 我们也可以编写自己的ClassLoader,去加载特定环境下的Jar文件。
  5. 能不能加载Jar,加载哪里的Jar,是由ClassLoader决定的。
  6. 楼主的问题可能是 导入的仅仅是jar包的引用,例如在eclipse中通过build path加进user lib……(类似快捷方式)
  7. 这种在Java Application中没问题,但在web Application中可能会出现找不到类的异常。
  8. 在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.ContextLoaderL的更多相关文章

  1. java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL,spring获取context

    今天学习spring项目的时候出现了下面的错误信息: java.lang.ClassNotFoundException: org.springframework.web.context.Context ...

  2. jeesite 经常出现java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL解决思路

    本来jeesite是用的maven,但是我开发的项目用这个框架没用maven, 经常报这个错,我能用的办法就是将springmvc—web.jar包删掉,然后重新添加

  3. 部署Maven项目到tomcat报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLi

    Maven项目下update maven后Eclipse报错:java.lang.ClassNotFoundException: ContextLoaderL     严重: Error config ...

  4. 真正解决问题:maven eclipse tomcat java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener--转

    原文地址:http://www.cnblogs.com/amosli/p/4067665.html 在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.Clas ...

  5. maven 项目启动tomcat报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    maven项目启动tomcat报错: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLi ...

  6. ssh项目java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoade错误

    错误: 导入别人的ssh项目后出现java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoade错误, 错 ...

  7. java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    参考: http://www.cnblogs.com/sunxucool/archive/2013/06/07/3124380.html   ---------------------------&g ...

  8. 真正解决问题:maven eclipse tomcat java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.ClassNotFoundException:org.springframework.web.context ...

  9. springmvc项目中java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 严重: Error co ...

随机推荐

  1. pfsense的nat配置

    需要把内网192.168.1.100的80端口映射到外面,外网卡地址为192.168.1.200 firewall, firewall,nat,选择port forward标签,添加一个 在desti ...

  2. push is not a function

    push is not a function 今天写js 碰上了这个问题 找了半天百度不得其解. 后来发现,我push的是一个对象 push数组才可以

  3. spring扩展点之三:Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法,在spring启动后做些事情

    <spring扩展点之三:Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法,在spring启动后做些事情> <服务网关zu ...

  4. 【转载】 java利用snmp4j包来读取snmp协议数据(Manager端)

    https://www.cnblogs.com/xdp-gacl/p/4187089.html http://doc.okbase.net/yuanfy008/archive/265663.html ...

  5. 1067 Sort with Swap(0, i) (25 分)

    1067 Sort with Swap(0, i) (25 分) Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy ...

  6. Dubbo各种协议

    协议参考手册 (+) (#) 推荐使用Dubbo协议 性能测试报告各协议的性能情况,请参见:性能测试报告 (+) dubbo:// (+) (#) Dubbo缺省协议采用单一长连接和NIO异步通讯,适 ...

  7. Oracle中分页查询和联表查询

    1.使用ROWNUM伪列查询 1.1.查询十条数据(rownum<=n) SELECT ROWNUM,A.* FROM v_sjjx_unit_info A WHERE ROWNUM<=1 ...

  8. Sublime Text 2 - 性感无比的代码编辑器!程序员必备神器!

    Sublime Text 2 - 性感无比的代码编辑器!程序员必备神器! http://www.iplaysoft.com/sublimetext.html 代码编辑器或者文本编辑器,对于程序员来说, ...

  9. javascript 中的函数声明和函数表达式区别

    函数声明格式: function add(a, b) { alert(a+b); } 函数表达式格式: var add = function (a, b) { alert(a+b); } 解析器在向环 ...

  10. UNDO三大作用与一致性读机制浅析

    UNDO三大作用1.一致性读(consistent read)2.事务回滚(Rollback Transaction)3.实例恢复(Instance Recovery) 一致性读当会话发出一条SQL查 ...