Bonjour,

Parfois lors de la connexion à mon application, j'ai l'erreur ci-dessous.
Je n'arrive vraiment pas à comprendre pourquoi se produit se problème.
Est-ce que cela peut venir d'un mauvais parametrage d'hibernate ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
05/10/2009 13:14:10,145 243493193 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager  - opening JDBC connection
05/10/2009 13:29:55,357 244438405 [http-8080-1] DEBUG org.hibernate.util.JDBCExceptionReporter  - Cannot open connection [???]
java.sql.SQLException: Exception d'E/S: Connection timed out
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
	at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:968)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
	at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1688)
	at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1654)
	at oracle.jdbc.driver.PhysicalConnection.setTransactionIsolation(PhysicalConnection.java:1591)
	at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:126)
	at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
	at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
	at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1573)
	at org.hibernate.loader.Loader.doQuery(Loader.java:696)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
	at org.hibernate.loader.Loader.doList(Loader.java:2228)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
	at org.hibernate.loader.Loader.list(Loader.java:2120)
	at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
	at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
	at org.springframework.orm.hibernate3.HibernateTemplate$35.doInHibernate(HibernateTemplate.java:984)
	at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
	at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:974)
	at fr.invs.a3s.dao.metier.impl.ADaoHb.liste(ADaoHb.java:135)
	at fr.invs.a3s.dao.metier.impl.PersonnelDAO.getParLogin(PersonnelDAO.java:43)
	at fr.invs.a3s.service.impl.PersonnelManager.getParLogin(PersonnelManager.java:69)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy36.getParLogin(Unknown Source)
	at fr.invs.a3s.util.spring.securite.UtilisateurDetailsServiceImpl.loadUserByUsername(UtilisateurDetailsServiceImpl.java:33)
	at org.springframework.security.providers.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:83)
	at org.springframework.security.providers.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:121)
	at org.springframework.security.providers.ProviderManager.doAuthentication(ProviderManager.java:188)
	at org.springframework.security.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:46)
	at org.springframework.security.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(AuthenticationProcessingFilter.java:82)
	at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:258)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.concurrent.ConcurrentSessionFilter.doFilterHttp(ConcurrentSessionFilter.java:99)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:619)
05/10/2009 13:29:55,357 244438405 [http-8080-2] DEBUG org.hibernate.connection.DriverManagerConnectionProvider  - opening new JDBC connection
05/10/2009 13:29:55,420 244438468 [http-8080-1] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 17002, SQLState: null
05/10/2009 13:29:55,436 244438484 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter  - Exception d'E/S: Connection timed out
05/10/2009 13:29:55,436 244438484 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager  - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
05/10/2009 13:29:55,437 244438485 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTemplate  - Not closing pre-bound Hibernate Session after HibernateTemplate
05/10/2009 13:29:55,441 244438489 [http-8080-1] DEBUG org.springframework.transaction.interceptor.TransactionInterceptor  - Completing transaction for [fr.invs.a3s.service.IPersonnelManager.getParLogin] after exception: org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [17002]; Exception d'E/S: Connection timed out; nested exception is java.sql.SQLException: Exception d'E/S: Connection timed out
05/10/2009 13:29:55,453 244438501 [http-8080-1] DEBUG org.springframework.transaction.interceptor.RuleBasedTransactionAttribute  - Applying rules to determine whether transaction should rollback on org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [17002]; Exception d'E/S: Connection timed out; nested exception is java.sql.SQLException: Exception d'E/S: Connection timed out

L'architecture utilisée est la suivante :
Java 1.6
Spring 2.5.6
Hibernate 3.3.1
Oracle 10g
Tomcat 6.0.18

J'utilise la librairie c3p0 pour gérer le pool de connexion dans hibernate.
J'utilise Spring security pour protéger les URL de l'application.
Les transactions d'hibernate sont gérées par Spring.
J'ai mis en place le pattern Session-In-View à fin d'utiliser les
chargement en Lazy des relations du modèle hibernate.

Mon fichier de configuration spring pour hibernate est définit comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
    <bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="configLocation">
            <value>classpath:/hibernate/hibernate.cfg.xml</value>
        </property>
    </bean>	
    <bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>
 
    <!-- bean du DAO -->
</beans>
Mo fichier spring gérant les transactions est le suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
	  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
	<import resource="applicationContext-hibernate.xml"/>
 
	<aop:config>
		<aop:advisor
			pointcut="execution(* fr.invs.a3s.service.I*.*(..))"
			advice-ref="txManager" />
	</aop:config>
 
	<tx:advice id="txManager">
		<tx:attributes>
			<tx:method name="sauve*" propagation="REQUIRES_NEW" />
			<tx:method name="supprime" propagation="REQUIRES_NEW" />
			<tx:method name="*" propagation="NOT_SUPPORTED" read-only="true"/>
		</tx:attributes>
	</tx:advice>
 
	<!-- Services beans -->
</beans>
Ma configuration d'hibernate:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <!-- Database connection settings -->
    <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:DEV</property>
    <property name="connection.username">PSWD</property>
    <property name="connection.password">PSWD</property>
    <property name="connection.autoReconnect">true</property>
    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
 
	<!-- Provide de pool de connexion utilisé -->
	<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
    <!-- Minimum number of JDBC connections that C3P0 keeps ready at all times. -->
    <property name="c3p0.min_size">10</property>
    <!-- maximum number of connections in the pool. An exception is thrown at runtime if this number is exhausted. -->
    <property name="c3p0.max_size">20</property>
    <!-- timeout period (in seconds) after which an idle connection is removed from the pool. -->
    <property name="c3p0.timeout">2700</property>
    <!-- prepared statements will be cached. Caching of prepared statements is essential for best performance with Hibernate. -->
    <property name="c3p0.max_statements">0</property>
 
    <!-- Enable Hibernate's automatic session context management -->
    <property name="current_session_context_class">thread</property>
    <!-- org.hibernate.cache.NoCacheProviderr -->
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
    <!-- Enable the second-level cache -->
    <property name="cache.use_second_level_cache">false</property>
 
    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">false</property>
    <!-- Pretty print the SQL in the log and console. -->
    <property name="format_sql">false</property>
    <!-- Generate comments inside the SQL, for easier debugging. -->
    <property name="use_sql_comments">false</property>
 
    <!-- Mapping Hibernate -->
 
  </session-factory>
</hibernate-configuration>
Enfin, le web.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <description>Application Test</description>
    <display-name>Test App</display-name>
 
    <!-- Démarrage de Spring -->
    <listener>
    	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
    </listener>
    <listener>
		<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
	</listener>
    <listener>
         <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
 
    <!-- Configuration de log4J -->
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
    </context-param>
 
    <!-- Extensions de configuration Spring -->
    <context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/conf/spring/applicationContext*.xml</param-value>
	</context-param>
 
    <filter>
      <filter-name>springSecurityFilterChain</filter-name>
      <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
 
    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
 
 
    <filter>
        <filter-name>Hibernate Session In View Filter</filter-name>
           <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>Hibernate Session In View Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
 
 
	<!-- Struts 2 config -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
 
    <!-- Tiles2 -->
    <servlet>
		<servlet-name>tiles</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
 
	<servlet-mapping>
		<servlet-name>tiles</servlet-name>
		<url-pattern>*.html</url-pattern>
	</servlet-mapping>
 
    
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>