今天学习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. koa2 知识点

    koa2 常用功能: 假设 Koa 提供的 Context 对象的实例为 ctx table th:first-of-type { width: 200px; } table th:nth-of-ty ...

  2. PHP安全相关的配置(2)

    php用越来越多!安全问题更为重要!这里讲解如果安全配置php.ini 安全配置一 (1) 打开php的安全模式 php的安全模式是个非常重要的内嵌的安全机制,能够控制一些php中的函数,比如syst ...

  3. Linq快速入门——扩展方法

    Linq为我们提供了许多扩展方法,方便我们对数据源进行操作(Where,Select...).即使你不了解算法,也能使用Linq当回牛人.扩展方法本质并不是什么高深的技术,说白了就是一个Static静 ...

  4. Spring中IOC与DI的的区别

    依赖注入的前提: 有IOC的环境,也就是将必须对象的创建权交给了Spring. DI 介绍 Dependency Injection 依赖注入.需要有IOC 的环境,Spring 创建这个类的过程中, ...

  5. linux 标准I/O (二)

    <Uinx 环境高级编程笔记>   以前经常遇到两种I/O操作 一类是f打头的fopen, fread, fwrite 一类是没有f打头的open, read, fwrite 原来一个是U ...

  6. Unigui的Grid添加汇总栏

  7. 小峰mybatis(4)mybatis使用注解配置sql映射器

    主流开发还是使用xml来配置:使用注解配置比较快,但是不支持所有功能:有些功能还是得用配置文件: 一.基本映射语句: @Inert @Update @Delete @Select 二.结果集映射语句 ...

  8. DOM节点的增删改查

    在开始展开DOM操作前,首先需要构建一棵DOM树. <!DOCTYPE html> <html lang="en"> <head> <me ...

  9. Work01

    7101:我是最酷的张绥:我的爱是弹吉他,唱歌,游泳,打篮球...: 我的博客是:https://www.cnblogs.com/Mrzs/ 我的码云个人主页是:https://gitee.com/s ...

  10. 安装HBase(0.9)数据库

    基本知识: 1.hbase是一种基于列存储的数据库,也就是说它的一列的数据是存储在一个文件里面的,而传统的数据库存储都是一个文件存储多个行,这些行有不同的列,这些列的数据类型 不同. 2.基于HDFS ...