java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
来源:互联网 发布:多元线性回归模型矩阵 编辑:程序博客网 时间:2024/05/16 11:44
观察是否还有异常:java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderServlet
所以ContextLoaderServlet 没有成功加载,导致web.xml构建spring容器失败!所以在引用WebApplicationContextUtils时,出现java.lang.NoClassDefFoundError:org/springframework/web/context/support/WebApplicationContextUtils
情况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:
<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
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
- 解决maven管理下,java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet服务器启动报异常
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet服务器启动报异常
- java.lang.ClassNotFoundException: org.springframework.web.context.Contb.context.
- 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.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- maven项目 报:java.lang.ClassNotFoundException: org.springframework.web.context...
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- 解决java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoader
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL
- [Spring]Annotation-based container configuration_AnotationBasis_01
- lintcode:Merge k Sorted Lists
- 通讯录
- Android API Guides---App Manifest <supports-gl-texture>
- asp.net中页面按钮回车默认执行 设置方法
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
- javascript练习题(一)
- const和static和static const
- 数学的魅力,php的美丽。
- php真静态缓存 ob系统函数
- 算法(读书笔记):4.3最小生成树
- 由Lua 粘合的Nginx生态环境
- Hive Runtime Error: Unable to deserialize reduce input key from
- iOS中点击button切换背景图片与点击切换背景颜色问题的解释