Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.69 KB | None | 0 0
  1. java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
  2.  
  3. <context-param>
  4. <param-name>contextConfigLocation</param-name>
  5. <param-value>
  6. /WEB-INF/springapp-servlet.xml
  7. </param-value>
  8. </context-param>
  9.  
  10. <listener>
  11. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  12. </listener>
  13.  
  14. org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.test.model.Store.categories, could not initialize proxy - no Session
  15.  
  16. <?xml version="1.0" encoding="ISO-8859-1"?>
  17.  
  18. <web-app version="2.4"
  19. xmlns="http://java.sun.com/xml/ns/j2ee"
  20. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  21. xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
  22. http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
  23. <display-name>
  24. Spring
  25. </display-name>
  26. <description>
  27. Spring Test
  28. </description>
  29.  
  30. <context-param>
  31. <param-name>contextConfigLocation</param-name>
  32. <param-value>
  33. /WEB-INF/springapp-servlet.xml
  34. </param-value>
  35. </context-param>
  36.  
  37. <listener>
  38. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  39. </listener>
  40.  
  41. <filter>
  42. <filter-name>hibernateFilter</filter-name>
  43. <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
  44. <init-param>
  45. <param-name>sessionFactoryBeanName</param-name>
  46. <param-value>sessionFactory</param-value>
  47. </init-param>
  48. </filter>
  49.  
  50. <filter-mapping>
  51. <filter-name>hibernateFilter</filter-name>
  52. <url-pattern>/*</url-pattern>
  53. <dispatcher>REQUEST</dispatcher>
  54. <dispatcher>FORWARD</dispatcher>
  55. </filter-mapping>
  56.  
  57. <servlet>
  58. <servlet-name>springapp</servlet-name>
  59. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  60. <load-on-startup>1</load-on-startup>
  61. </servlet>
  62.  
  63.  
  64.  
  65. <servlet-mapping>
  66. <servlet-name>springapp</servlet-name>
  67. <url-pattern>/</url-pattern>
  68. </servlet-mapping>
  69.  
  70. <error-page>
  71. <error-code>500</error-code>
  72. <location>/error/500</location>
  73. </error-page>
  74. <error-page>
  75. <error-code>404</error-code>
  76. <location>/resources/pages/error.html</location>
  77. </error-page>
  78.  
  79.  
  80.  
  81. </web-app>
  82.  
  83. <?xml version="1.0" encoding="UTF-8"?>
  84.  
  85. <beans xmlns="http://www.springframework.org/schema/beans"
  86. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  87. xmlns:context="http://www.springframework.org/schema/context"
  88. xmlns:mvc="http://www.springframework.org/schema/mvc"
  89. xmlns:aop="http://www.springframework.org/schema/aop"
  90. xmlns:tx="http://www.springframework.org/schema/tx"
  91. xsi:schemaLocation="http://www.springframework.org/schema/mvc
  92. http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
  93. http://www.springframework.org/schema/beans
  94. http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  95. http://www.springframework.org/schema/context
  96. http://www.springframework.org/schema/context/spring-context-3.2.xsd
  97. http://www.springframework.org/schema/tx
  98. http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
  99. http://www.springframework.org/schema/aop
  100. http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
  101.  
  102. <context:component-scan base-package="com.test.web.controllers,com.test.service.impl" />
  103.  
  104. <mvc:annotation-driven />
  105. <mvc:resources mapping="/resources/**" location="/resources/" />
  106.  
  107. <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  108. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  109. <property name="url" value="jdbc:mysql://localhost:3306/test?zeroDateTimeBehavior=convertToNull"/>
  110. <property name="username" value="spring"/>
  111. <property name="password" value="test"/>
  112. </bean>
  113.  
  114. <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  115. <property name="dataSource" ref="myDataSource"/>
  116. <property name="mappingLocations" value="classpath*:com/test/model/hbm/**/*.hbm.xml" />
  117.  
  118. <property name="hibernateProperties">
  119. <value>
  120. hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
  121. hibernate.show_sql=true
  122. </value>
  123. </property>
  124. </bean>
  125.  
  126. <tx:annotation-driven />
  127. <bean id="transactionManager"
  128. class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  129. <property name="sessionFactory" ref="sessionFactory"/>
  130. </bean>
  131.  
  132.  
  133. <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
  134. <property name="resourceLoaderPath" value="/WEB-INF/templates/"/>
  135. </bean>
  136. <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
  137. <property name="cache" value="true"/>
  138. <property name="prefix" value=""/>
  139. <property name="suffix" value=".vm"/>
  140. <property name="layoutUrl" value="index.vm" />
  141.  
  142. <!-- if you want to use the Spring Velocity macros, set this property to true -->
  143. <property name="exposeSpringMacroHelpers" value="true"/>
  144.  
  145. </bean>
  146.  
  147. <bean id="multipartResolver"
  148. class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  149.  
  150. <!-- one of the properties available; the maximum file size in bytes -->
  151. <property name="maxUploadSize" value="10000000" />
  152. </bean>
  153.  
  154. <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
  155.  
  156. <bean id="categoryDAO" class="com.test.dao.hibernate.HibernateCategoryDAO">
  157. <property name="sessionFactory" ref="sessionFactory"></property>
  158. </bean>
  159. <bean id="categoryService" class="com.test.service.Categories" scope="singleton">
  160. <property name="dao" ref="categoryDAO"></property>
  161. </bean>
  162. <bean id="storeDAO" class="com.test.dao.hibernate.HibernateStoreDAO">
  163. <property name="sessionFactory" ref="sessionFactory"></property>
  164. </bean>
  165. <bean id="storeService" class="com.test.service.Stores" scope="singleton">
  166. <property name="dao" ref="storeDAO"></property>
  167. <property name="categoryDao" ref="categoryDAO"></property>
  168.  
  169. </bean>
  170.  
  171. </beans>
  172.  
  173. <context-param>
  174. <param-name>contextConfigLocation</param-name>
  175. <param-value>
  176. /WEB-INF/springapp.xml
  177. </param-value>
  178. </context-param>
  179.  
  180. <listener>
  181. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  182. </listener>
  183.  
  184. <filter>
  185. <filter-name>hibernateFilter</filter-name>
  186. <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
  187. <init-param>
  188. <param-name>sessionFactoryBeanName</param-name>
  189. <param-value>sessionFactory</param-value>
  190. </init-param>
  191. </filter>
  192.  
  193. <filter-mapping>
  194. <filter-name>hibernateFilter</filter-name>
  195. <url-pattern>/*</url-pattern>
  196. <dispatcher>REQUEST</dispatcher>
  197. <dispatcher>FORWARD</dispatcher>
  198. </filter-mapping>
  199.  
  200. <servlet>
  201. <servlet-name>springapp</servlet-name>
  202. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  203. <init-param>
  204. <param-name>contextConfigLocation</param-name>
  205. <param-value>/WEB-INF/springapp-servlet.xml</param-value>
  206. </init-param>
  207.  
  208. <load-on-startup>1</load-on-startup>
  209. </servlet>
  210.  
  211.  
  212.  
  213. <servlet-mapping>
  214. <servlet-name>springapp</servlet-name>
  215. <url-pattern>/</url-pattern>
  216. </servlet-mapping>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement