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

今天在进行了项目的整合的时候使用的是maven工具,当我的项目整合成功以后启动web容器发现了报了下面的异常:

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

java.lang.ClassNotFoundException: org.springframework.web.util.WebAppRootListener

在我的项目当中我也确实配置了下面的信息:

<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>
	<listener>
		<listener-class>org.springframework.web.util.WebAppRootListener
		</listener-class>
	</listener>

开始以为是我的classpath的路径配置出了问题,但是发现我的配置也没有问题,和我项目中的目录相符合:

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			classpath:applicationContext.xml
		</param-value>
	</context-param>

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

开始还不知为什么,到后来在网上找了写资料终于找到了解决的方法和缘由:

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便能顺利通过了。

注意:不能再build path了,因为maven会自动的引入jar,假如再添加进去了就会有jar的冲突问题。

  1. spring-web 的jar包没导进去
  2. jar包邮冲突,把重复的jar包删除
  3. 在web.xml加上<context-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>classpath:applicationContext-*.xml</param-value>

    </context-param>

因为默认的读取的是/WEB-INF下的配置文件,如果配置文件在src中要把路径改为类路径底下

4.把工程刷新一下,因为工程是部署在服务器底下的,要把加入的jar包部署到工程里。

时间: 2024-08-05 07:21:31

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener java.lang.Cl的相关文章

java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener问题解决

今天搭建SSH项目的时候出现了例如以下错误: 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 网上查了一下.有些人说是没有spring的相关包.可是我检查这个包

maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

maven 导入项目中经常出现这个问题 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 在网上找了些资料,有的说是少jar包,把有关spring的jar包复制到

maven项目出现:Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

今天安装和部署maven项目的时候一直都出现这样的错误:  maven项目出现:Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener  按照网上的好多都是说spring.jar包什么的问题,但是我这个项目修改了也没有效果的样子,后来自己尝试了一下,发现是maven的包没成功导入项目中: 在eclipse中:如果在这样:右击 Maven project -

【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

今天搭建新的项目,虽然在web.xml中配置了ContextLoaderListener以及IntrospectorCleanupListener 如下: web.xml中部分代码: 1 <!-- 监听servletContext,启动contextConfigLocation中的spring配置信息 --> 2 <listener> 3 <listener-class>org.springframework.web.context.ContextLoaderListe

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

在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener 这时里的意思是说找不到jar包,如果使用的是maven管理jar包,会发现jar包明明已经有了,但还是报错:如果mvn package生成一个war包发布到tomcat下面会发现,其实项目是没问题的. 1.出现这个问题的原因有可能的其中一点就是sprin

在eclipse中运行spring web application时的异常: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener....... tomcat再发布web项目时,并没有将maven的依赖包一起随项目的编译一并进行打包. 解决办法

idea调试SpringMvc, 出现:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener错误的解决办法

有时,使用idea开发SpringMvc发现调试时出现以下错误: 12-Mar-2017 12:08:02.345 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class org.springframework.web.context.ContextLoaderListene

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

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListenerjava.lang.ClassNotFoundException: org.springframework.web

maven创建spring项目之后,启动报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

出错情景:maven中已经加载了spring的核心包,但是项目启动时,报错: org.apache.catalina.core.StandardContext listenerStart严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListenerjava.lang.ClassNotFoundException: org.springframewor