java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet服务器启动报异常

今天配置的Tomcat服务器,启动springMVC项目,报java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet异常,还有异常:java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderServlet等异常,解决问题网上查了很多资料,特意总结如下:

情况1:

WebApplicationContext wctx=WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

我的spring-web.jsr的包已经加上了,为什么程序运行时,找不到WebApplicationContextUtils类呢?

有一个教程上说了这样的一句话,我不理解是什么意思“在Action初始化时获得一个应用程序上下文。重用spring的WebApplicationContextUtils类,如果没有可用的上下文,该动作不会正确的初始化”。

情况2:

你的工程包有可能都是引用的,需要把它们都手动拷贝到工程中来!

情况3:

spring框架有自已内在一套映射机制,楼主的问题是由于没有找到相应的映射BEAN引用而产生!

<context-param>

<param-name>contextconfiglocation</param-name>

<param-value>com/wenjing/hibernate/test/wenjing-servlet.xml</param-value>

</context-param>

这一段换一种方式试一试,可以写到spring-servlet.xml当中引用

内容如下 :

<bean id="newBaseAction" class="db.PBaseAction">
<property name="view"><value>newBaseAction</value></property>
</bean>   

情况4:

你用的是hibernate3.0吧! 但你的spring配置文件中不是

<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">

应该是:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

你试试!

情况5:

关键字: Spring与Web应用集成的方法细讲

1、将spring的相关jar包,拷贝到web应用的WEB-INF/lib目录下

2、修改web.xml,让应用服务器自动加载spring的BeanFactory对象

<context-param>
    <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener> 

3、在web组件里,可以使用WebApplicationContextUtils工具类来 获得BeanFactory对象的实例,拥有了BeanFactory对象,就拥有 了spring的容器管理的能力。

解释:

这种配置的结果是,spring通过ContextLoaderListener将WebApplicationContext对象

(BeanFactory的子类)放入ServletContext中,并取名为一个静态变量的值:

WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE

* 通过WebApplicationContextUtils.getApplicationContext()方法就可以获得WebApplicationContext

对象的值

* 或者通过request.getSession().getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICAT

时间: 2024-07-29 15:43:12

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet服务器启动报异常的相关文章

spring异常 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet

情况1:工程没有添加jar包引用 情况2:(最雷人的错误~)你的工程jar包可能都是引用的,需要把它们手动拷贝到工程里来! 情况3:没有配置spring的映射Bean引用 情况4:spring bean配置的类在当前spring版本中没有

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的依赖包一起随项目的编译一并进行打包. 解决办法

spring项目后出现java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoade

导入别人的spring项目后出现java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoade错误, 解决: 1.若项目的主人是用maven创建spring项目, 解决办法: 项目 -> 属性 -> Deployment Assembly -> Add -> Java Build Path Entries -> 选择Maven Dependencies -> Finish -&

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

今天学习spring项目的时候出现了下面的错误信息: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) at org.apache.catalina.loader.WebappClassLoader.