Java - Config XML persistencia Hibernate C3P0 - Spring mvc

 
Vista:

Config XML persistencia Hibernate C3P0 - Spring mvc

Publicado por Newbie83 (37 intervenciones) el 28/06/2017 16:07:08
Buenas.

Tengo el siguiente xml de configuración con la base de datos:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
		http://www.springframework.org/schema/jee 
		http://www.springframework.org/schema/jee/spring-jee-4.0.xsd">
 
	<context:component-scan base-package="es.company.sistema.persistencia" />
 
	<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="packagesToScan" value="es.mipaquete.modelo"></property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
				<prop key="hibernate.show_sql">false</prop>
			</props>
		</property>
	</bean>
 
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
 
		<property name="connection.driver_class" value="com.mysql.jdbc.Driver" />
		<property name="connection.url" value="jdbc:mysql://localhost:3306/sistema" />
		<property name="connection.username" value="root" />
		<property name="connection.password" value="root" />
 
	  	<property name="hibernate.c3p0.min_size" value="5" />
	  	<property name="hibernate.c3p0.max_size" value="20" />
	  	<property name="hibernate.c3p0.timeout" value="1800"/>
	  	<property name="hibernate.c3p0.max_statements" value="50" />
 
	    <property name="hibernate.c3p0.testConnectionOnCheckout" value="true" />
 
	    <property name="hibernate.c3p0.privilegeSpawnedThreads" value="true" />
		<property name="hibernate.c3p0.contextClassLoaderSource" value="library" />
 
	</bean>
 
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
 
	<bean id="persistenceExceptionTranslationPostProcessor"
		class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
 
	<tx:annotation-driven transaction-manager="transactionManager" />
 
</beans>

Funciona perfectamente pero al cabo de 8 horas deja de funcionar. Obtengo el error:

ERROR: Already closed.
25-may-2017 8:45:23 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: El Servlet.service() para el servlet [dispatcher] en el contexto con ruta [/miprograma] lanzó la excepción [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin transaction failed: ] con causa raíz
java.net.SocketException: Software caused connection abort: recv failed

¿Alguien me puede echar una mano? Parece que no hay forma de solucionar esto...

Gracias y saludos.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder