当前位置: 代码迷 >> Web前端 >> struts+spring+hibernate架构上报No WebApplicationContext found
  详细解决方案

struts+spring+hibernate架构上报No WebApplicationContext found

热度:567   发布时间:2013-09-11 17:59:55.0
struts+spring+hibernate架构下报No WebApplicationContext found

错误原因:我看不懂...

java 代码
  1. type?Exception?report ??
  2. ??
  3. message? ??
  4. ??
  5. description?The?server?encountered?an?internal?error?()?that?prevented?it?from?fulfilling?this?request. ??
  6. ??
  7. exception? ??
  8. ??
  9. javax.servlet.ServletException:?No?WebApplicationContext?found:?no?ContextLoaderListener?registered? ??
  10. ????org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545) ??
  11. ????org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486) ??
  12. ????org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274) ??
  13. ????org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) ??
  14. ????org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) ??
  15. ????javax.servlet.http.HttpServlet.service(HttpServlet.java:710) ??
  16. ????javax.servlet.http.HttpServlet.service(HttpServlet.java:803) ??
  17. ??
  18. ??
  19. root?cause? ??
  20. ??
  21. java.lang.IllegalStateException:?No?WebApplicationContext?found:?no?ContextLoaderListener?registered? ??
  22. ????org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:84) ??
  23. ????org.springframework.web.struts.DelegatingActionUtils.findRequiredWebApplicationContext(DelegatingActionUtils.java:122) ??
  24. ????org.springframework.web.struts.DelegatingActionProxy.getWebApplicationContext(DelegatingActionProxy.java:139) ??
  25. ????org.springframework.web.struts.DelegatingActionProxy.getDelegateAction(DelegatingActionProxy.java:120) ??
  26. ????org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:105) ??
  27. ????org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484) ??
  28. ????org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274) ??
  29. ????org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) ??
  30. ????org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) ??
  31. ????javax.servlet.http.HttpServlet.service(HttpServlet.java:710) ??
  32. ????javax.servlet.http.HttpServlet.service(HttpServlet.java:803) ??
  33. ??
  34. ??
  35. note?The?full?stack?trace?of?the?root?cause?is?available?in?the?Apache?Tomcat/5.5.23?logs. ??

[b]web.xml:[/b]

java 代码
  1. <?xml?version="1.0"?encoding="UTF-8"?> ??
  2. <web-app?xmlns="http://java.sun.com/xml/ns/j2ee"?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?version="2.4"?xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee???http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> ??
  3. ??<servlet> ??
  4. ????<servlet-name>action</servlet-name> ??
  5. ????<servlet-class>org.apache.struts.action.ActionServlet</servlet-class> ??
  6. ????<init-param>??? ??
  7. ????????<param-name>contextConfigLocation</param-name>??? ??
  8. ????????<param-value>classpath:applicationContext.xml</param-value>??? ??
  9. ????</init-param> ??
  10. ????<init-param> ??
  11. ??????<param-name>config</param-name> ??
  12. ??????<param-value>/WEB-INF/struts-config.xml</param-value> ??
  13. ????</init-param> ??
  14. ???? ??
  15. ????<init-param> ??
  16. ??????<param-name>debug</param-name> ??
  17. ??????<param-value>3</param-value> ??
  18. ????</init-param> ??
  19. ????<init-param> ??
  20. ??????<param-name>detail</param-name> ??
  21. ??????<param-value>3</param-value> ??
  22. ????</init-param> ??
  23. ????<load-on-startup>0</load-on-startup> ??
  24. ??</servlet> ??
  25. ??<servlet-mapping> ??
  26. ????<servlet-name>action</servlet-name> ??
  27. ????<url-pattern>*.do</url-pattern> ??
  28. ??</servlet-mapping> ??
  29. </web-app> ??


[[b]struts-config.xml:[/b]

java 代码
  1. <?xml?version="1.0"?encoding="UTF-8"?> ??
  2. <!DOCTYPE?struts-config?PUBLIC?"-//Apache?Software?Foundation//DTD?Struts?Configuration?1.1//EN"?"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> ??
  3. ??
  4. <struts-config> ??
  5. ??<data-sources?/> ??
  6. ??<form-beans?> ??
  7. ????<form-bean?name="loginForm"?type="com.dn.struts.form.LoginForm"?/> ??
  8. ??
  9. ??</form-beans> ??
  10. ??
  11. ??<global-exceptions?/> ??
  12. ??<global-forwards?/> ??
  13. ??<action-mappings?> ??
  14. ????<action ??
  15. ??????attribute="loginForm"??
  16. ??????input="/form/login.jsp"??
  17. ??????name="loginForm"??
  18. ??????parameter="parm"??
  19. ??????path="/login"??
  20. ??????scope="request"??
  21. ??????type="org.springframework.web.struts.DelegatingActionProxy"?> ??
  22. ??????<forward?name="success"?path="/form/success.jsp"?/> ??
  23. ??????<forward?name="error"?path="/form/error.jsp"?/> ??
  24. ????</action> ??
  25. ??
  26. ??
  27. ??</action-mappings> ??
  28. ??
  29. ??<message-resources?parameter="com.dn.struts.ApplicationResources"?/> ??
  30. </struts-config> ??

[b]applicationContext.xml:[/b]

java 代码
  1. <?xml?version="1.0"?encoding="UTF-8"?> ??
  2. <!DOCTYPE?beans?PUBLIC?"-//SPRING//DTD?BEAN//EN"?"http://www.springframework.org/dtd/spring-beans.dtd"> ??
  3. ??
  4. <beans> ??
  5. ??
  6. ????<!--数据源datasource的声明--> ??
  7. ????<bean?id="dataSource"?class="org.apache.commons.dbcp.BasicDataSource"?destroy-method="close"> ??
  8. ????????<property?name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property> ??
  9. ????????<property?name="url"><value>jdbc:oracle:thin:@127.0.0.1:1521:datanew</value></property> ??
  10. ????????<property?name="username"><value>test</value></property> ??
  11. ????????<property?name="password"><value>test</value>???</property>????? ??
  12. ????</bean> ??
  13. ???? ??
  14. ????<!--Session?Factory声明--> ??
  15. ????<bean?id="sessionFactory"?class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> ??
  16. ????????<property?name="dataSource"> ??
  17. ????????????<ref?local="dataSource"?/> ??
  18. ????????</property> ??
  19. ????????<property?name="mappingResources"> ??
  20. ????????????<list> ??
  21. ????????????<value>com/dn/struts/entity/Login.hbm.xml</value> ??
  22. ????????????</list> ??
  23. ????????</property> ??
  24. ????????<property?name="hibernateProperties"> ??
  25. ????????????<props> ??
  26. ????????????????<prop?key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop> ??
  27. ????????????????<prop?key="hibernate.show_sql">true</prop> ??
  28. ????????????</props> ??
  29. ????????</property> ??
  30. ????</bean> ??
  31. ???? ??
  32. ????<!--定义一个hibernate?拦截器?--> ??
  33. ????<bean?id="hibernateInterceptor"?class="org.springframework.orm.hibernate3.HibernateInterceptor"> ??
  34. ????????<property?name="sessionFactory"> ??
  35. ????????????<ref?bean="sessionFactory"?/> ??
  36. ????????</property> ??
  37. ????</bean> ??
  38. ??
  39. ????<!--?hibernate?事务--> ??
  40. ????<bean?id="myTransactionManager"?class="org.springframework.orm.hibernate3.HibernateTransactionManager"> ??
  41. ????????<property?name="sessionFactory"> ??
  42. ????????????<ref?local="sessionFactory"?/> ??
  43. ????????</property> ??
  44. ????</bean> ??
  45. ???? ??
  46. ????<!--真正的DAO层--> ??
  47. ????<bean?id="basedaoTarget"?class="com.dn.dao.BaseDAO"> ??
  48. ????????<property?name="sessionFactory"> ??
  49. ????????????<ref?bean="sessionFactory"?/> ??
  50. ????????</property> ??
  51. ????</bean> ??
  52. ??
  53. ????<!--代理的DAO层?--> ??
  54. ????<bean?id="basedao"?class="org.springframework.aop.framework.ProxyFactoryBean"> ??
  55. ????????<property?name="proxyInterfaces"> ??
  56. ????????????<value>com.dn.dao.IBaseDAO</value> ??
  57. ????????</property> ??
  58. ????????<property?name="interceptorNames"> ??
  59. ????????????<list> ??
  60. ????????????????<value>hibernateInterceptor</value> ??
  61. ????????????????<value>basedaoTarget</value> ??
  62. ????????????</list> ??
  63. ????????</property> ??
  64. ????</bean> ??
  65. ???? ??
  66. ????<!--?真正的服务层?修改bean中id属性和class属性--> ??
  67. ????<bean?id="userServiceTarget"?class="com.dn.struts.service.UserService"> ??
  68. ????????<property?name="basedao"> ??
  69. ????????????<ref?bean="basedao"?/> ??
  70. ????????</property> ??
  71. ????</bean> ??
  72. ??
  73. ????<!--?代理的服务层?修改bean中id属性和ref中的bean的属性并且等于真正的服务层的bean的id属性--> ??
  74. ????<bean?id="userService"?class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> ??
  75. ????????<property?name="transactionManager"> ??
  76. ????????????<ref?bean="myTransactionManager"?/> ??
  77. ????????</property> ??
  78. ????????<property?name="target"> ??
  79. ????????????<ref?bean="userServiceTarget"?/> ??
  80. ????????</property> ??
  81. ????????<property?name="transactionAttributes"> ??
  82. ????????????<props> ??
  83. ????????????????<prop?key="get*">PROPAGATION_SUPPORTS</prop> ??
  84. ????????????????<prop?key="*">PROPAGATION_REQUIRED</prop> ??
  85. ????????????</props> ??
  86. ????????</property> ??
  87. ????</bean> ??
  88. ???? ??
  89. ????<!--?strtus控制器的配置?ref中的bean属性等于代理层中的bean中的id属性--> ??
  90. ????<bean?name="/login"?class="com.dn.struts.action.LoginAction"> ??
  91. ????????<property?name="iUserService"> ??
  92. ????????????<ref?bean="userService"?/> ??
  93. ????????</property> ??
  94. ????</bean> ??
  95. ???? ??
  96. </beans> ??


请各位大侠告诉小弟该怎么解决丫!还有我这种结构在ssh架构的基础上合理吗?
谢谢啦!...

[附件注释:项目的源代码.但是lib目录下面的jar包都没有.大家自己导入.我的开发工具是eclipse3.2.开发环境是struts1.1+Spring1.2 Core Libraries+Hibernate3.1 Core Libraries.数据库在applicationContext.xml文件中配置.当前数据库是oracle9i.数据库有3列.id是用序列自动增长的.]

1 楼 neitnaco 2007-10-25  
为什么没人帮我解决呢..我都放好几天了耶..郁闷中...

我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
  相关解决方案