I'm trying to make a web application that integrates Spring and Hibernate. What I get is not an exception, but my log continues to generate messages that, in my opinion, underline a problem in the db generation\connection. I declared an hsql database that I can access by the hsql swing manager, but the db file is not visible in the file explorer. Instead of test.db I get the following files:
- testdb.lck
- testdb.log
- testdb.properties
- testdb.script
The log warning is the following message; googling around it seems not to be a problem, but the message are generated around every second, seeming to close all the connection pool and creating new istances:
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1550) - BEGIN check for expired resources. [com.mchange.v2.resourcepool.BasicResourcePool@788c1852]
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1632) - EXPIRED idle resource: com.mchange.v2.c3p0.impl.NewPooledConnection@400ba6f6 ---> idle_time: 8513; max_idle_time: 7000 [com.mchange.v2.resourcepool.BasicResourcePool@788c1852]
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1561) - Removing expired resource: com.mchange.v2.c3p0.impl.NewPooledConnection@400ba6f6 [com.mchange.v2.resourcepool.BasicResourcePool@788c1852]
17/06/2015 16:04:11 - DEBUG - (ThreadPoolAsynchronousRunner.java:236) - com.mchange.v2.async.ThreadPoolAsynchronousRunner@60eb9f58: Adding task to queue -- com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@31b75e54
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1022) - Preparing to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@400ba6f6
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1747) - trace com.mchange.v2.resourcepool.BasicResourcePool@788c1852 [managed: 1, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@a62b39f)
17/06/2015 16:04:11 - DEBUG - (C3P0PooledConnectionPool.java:616) - Preparing to destroy PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@400ba6f6
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1747) - trace com.mchange.v2.resourcepool.BasicResourcePool@788c1852 [managed: 1, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@a62b39f)
17/06/2015 16:04:11 - DEBUG - (GooGooStatementCache.java:355) - ENTER METHOD: closeAll( org.hsqldb.jdbc.JDBCConnection@4795dda9 )! -- num_connections: 0
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1571) - FINISHED check for expired resources. [com.mchange.v2.resourcepool.BasicResourcePool@788c1852]
17/06/2015 16:04:11 - DEBUG - (GooGooStatementCache.java:394) - closeAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 0; checked out: 0; num connections: 0; num keys: 0
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:450) - incremented pending_acquires: 1
17/06/2015 16:04:11 - DEBUG - (NewPooledConnection.java:646) - com.mchange.v2.c3p0.impl.NewPooledConnection@400ba6f6 closed by a client.
java.lang.Exception: DEBUG -- CLOSE BY CLIENT STACK TRACE
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:646)
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:259)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:619)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1024)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)
17/06/2015 16:04:11 - DEBUG - (C3P0PooledConnectionPool.java:627) - Successfully destroyed PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@400ba6f6
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1788) - Starting acquisition series. Incremented pending_acquires [1], attempts_remaining: 30
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1027) - Successfully destroyed resource: com.mchange.v2.c3p0.impl.NewPooledConnection@400ba6f6
17/06/2015 16:04:11 - DEBUG - (ThreadPoolAsynchronousRunner.java:236) - com.mchange.v2.async.ThreadPoolAsynchronousRunner@60eb9f58: Adding task to queue -- com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@7d91f64b
17/06/2015 16:04:11 - DEBUG - (GooGooStatementCache.java:333) - checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 0; checked out: 0; num connections: 0; num keys: 0
17/06/2015 16:04:11 - DEBUG - (C3P0PooledConnectionPool.java:283) - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@49833c9c.acquireResource() returning.
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1747) - trace com.mchange.v2.resourcepool.BasicResourcePool@788c1852 [managed: 2, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@a62b39f)
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:471) - decremented pending_acquires: 0
17/06/2015 16:04:11 - DEBUG - (BasicResourcePool.java:1825) - Acquisition series terminated successfully. Decremented pending_acquires [0], attempts_remaining: 30
This message seems to repeat endlessy.
My configuration files are:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Fantacalcio</display-name>
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-database.xml,WEB-INF/spring-mvc-servlet.xml</param-value>
</context-param>
</web-app>
spring-mvc-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
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.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<beans:bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/pages/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<tx:annotation-driven />
<context:component-scan base-package="org.fabrizio.fantacalcio.controller" />
</beans:beans>
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:file:C:\\hsqldb-2.3.2\\hsqldb\\test.db</property>
<property name="hibernate.connection.username">SA</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.jdbc.batch_size">1000</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.provider_class">org.hibernate.c3p0.internal.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.timeout">7</property> <!-- secondi -->
<property name="hibernate.c3p0.max_statements">10</property>
<property name="hibernate.c3p0.idle_test_period">3000</property><!-- millisecondi -->
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.validate">false</property>
<property name="hibernate.c3p0.checkoutTimeout">2000</property><!-- millisecondi -->
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- <property name="hibernate.current_session_context_class">thread</property>-->
<property name="hibernate.id.new_generator_mappings">true</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="hibernate.generate_statistics">true</property>
<mapping class="org.fabrizio.fantacalcio.model.beans.Utente"/>
<mapping class="org.fabrizio.fantacalcio.model.beans.Ruolo"/>
<mapping class="org.fabrizio.fantacalcio.model.beans.Calciatore"/>
<mapping class="org.fabrizio.fantacalcio.model.beans.Formazione"/>
<mapping class="org.fabrizio.fantacalcio.model.beans.Partita"/>
<mapping class="org.fabrizio.fantacalcio.model.beans.Scontro"/>
<mapping class="org.fabrizio.fantacalcio.model.beans.SquadraFantacalcio"/>
<mapping class="org.fabrizio.fantacalcio.model.beans.SquadraReale"/>
<mapping class="org.fabrizio.fantacalcio.model.beans.StagioneFantacalcio"/>
</session-factory>
</hibernate-configuration>
spring-database.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
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.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<beans:bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="configLocation" value="classpath:hibernate.cfg.xml" />
</beans:bean>
<beans:bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="sessionFactory" />
</beans:bean>
</beans:beans>
Sorry for the code formatting but it seems not to like xml very much, hoping someone edits my message.