Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.31 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-configuration PUBLIC
  3. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  4. "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  5.  
  6. <hibernate-configuration>
  7. <session-factory>
  8. <!-- Database connection settings -->
  9. <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  10. <property name="connection.url">jdbc:mysql://localhost:3306/sometable</property>
  11. <property name="connection.username">root</property>
  12. <property name="connection.password">somepassword</property>
  13.  
  14. <!-- JDBC connection pool (use the built-in) -->
  15. <property name="connection.pool_size">1</property>
  16.  
  17. <!-- SQL dialect -->
  18. <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  19.  
  20. <!-- Echo all executed SQL to stdout -->
  21. <property name="show_sql">true</property>
  22.  
  23. <!-- All Entity Classes for hibernate to check for annotations here -->
  24.  
  25. <mapping class ="data.Person"/>
  26. </session-factory>
  27. </hibernate-configuration>
  28.  
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <beans xmlns="http://www.springframework.org/schema/beans"
  31. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
  32. xmlns:tx="http://www.springframework.org/schema/tx"
  33. xsi:schemaLocation="
  34. http://www.springframework.org/schema/beans
  35. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  36. http://www.springframework.org/schema/tx
  37. http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  38. http://www.springframework.org/schema/aop
  39. http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
  40.  
  41.  
  42. <bean id="sessionFactory" scope="singleton"
  43. class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  44. <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
  45. </bean>
  46.  
  47. <!-- Springs Hibernate Transaction Manager -->
  48. <bean id ="transactionManager" class = "org.springframework.orm.hibernate4.HibernateTransactionManager">
  49. <property name = "sessionFactory" ref = "sessionFactory"/>
  50. </bean>
  51.  
  52. <tx:annotation-driven transaction-manager="transactionManager"/>
  53.  
  54. <!-- Inject my business services class to the action -->
  55. <bean id="services" class ="services.Services" scope ="singleton">
  56. <property name = "sessionFactory" ref = "sessionFactory"/>
  57. </bean>
  58.  
  59.  
  60.  
  61. </beans>
  62.  
  63. Dec 02, 2012 11:36:39 PM org.apache.catalina.core.StandardContext listenerStart
  64. SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  65. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
  66. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
  67. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  68. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
  69. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
  70. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
  71. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
  72. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  73. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
  74. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
  75. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
  76. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
  77. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
  78. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
  79. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
  80. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
  81. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  82. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
  83. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
  84. at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
  85. at java.util.concurrent.FutureTask.run(Unknown Source)
  86. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  87. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  88. at java.lang.Thread.run(Unknown Source)
  89. Caused by: org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
  90. at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.unwrap(DriverManagerConnectionProviderImpl.java:91)
  91. at org.springframework.orm.hibernate4.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:101)
  92. at org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:264)
  93. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
  94. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
  95. ... 22 more
  96.  
  97. Dec 02, 2012 11:36:39 PM org.apache.catalina.core.StandardContext startInternal
  98. SEVERE: Error listenerStart
  99. Dec 02, 2012 11:36:39 PM org.apache.catalina.core.StandardContext startInternal
  100. SEVERE: Context [/Events] startup failed due to previous errors
  101. Dec 02, 2012 11:36:39 PM org.apache.catalina.core.ApplicationContext log
  102. INFO: Closing Spring root WebApplicationContext
  103. Dec 02, 2012 11:36:39 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
  104. SEVERE: The web application [/Events] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
  105. 4600 [pool-2-thread-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
  106. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
  107. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
  108. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  109. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
  110. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
  111. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
  112. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
  113. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  114. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
  115. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
  116. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
  117. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
  118. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
  119. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
  120. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
  121. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
  122. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  123. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
  124. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
  125. at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
  126. at java.util.concurrent.FutureTask.run(Unknown Source)
  127. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  128. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  129. at java.lang.Thread.run(Unknown Source)
  130. Caused by: org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
  131. at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.unwrap(DriverManagerConnectionProviderImpl.java:91)
  132. at org.springframework.orm.hibernate4.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:101)
  133. at org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:264)
  134. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
  135. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
  136. ... 22 more
  137.  
  138. <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  139. <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/Elec</property>
  140. <property name="hibernate.connection.username">root</property>
  141. <property name="hibernate.connection.password">123</property>
  142.  
  143. <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  144. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  145. <property name="url" value="jdbc:mysql://localhost:3306/Elec"/>
  146. <property name="username" value="root"/>
  147. <property name="password" value="123"/>
  148. </bean>
  149.  
  150.  
  151.  
  152. <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
  153. <property name="dataSource" ref="dataSource"/>
  154. <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
  155. </bean>
  156.  
  157. <bean id="txManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
  158. <property name="sessionFactory" ref="sessionFactory"></property>
  159. </bean>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement