java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
来源:互联网 发布:js设置button的显示值 编辑:程序博客网 时间:2024/06/05 16:02
观察是否还有异常: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
- Div布局实现Div等高的方法
- 转载:中国电信CDMA网络各地区SID分配
- Android 自定义控件-SnakeLayout (仿gallery)
- 桌面安全设置
- nginx的根目录设置会受到php.ini中 doc_root 的设置影响
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
- 分享最新20款非常棒的 CSS 工具
- android
- contentProvider
- java的内存泄露,转帖
- 关于datawindow重复行的一些filter操作
- combobox控件使用
- tomcat7的新功能特性
- stretchableImageWithLeftCapWidth