Rechargement continu du contexte d'application Spring et closing persistence
Bonjour,
Je rencontre un fonctionnement dans lequel le contexte d'application est tout le temps en train de se recharger, la persistance se ferme etc.
N'ayant pas de grande expérience dans le domaine je suis assez surpris...
Mon test consiste en un tableau qui affiche des personnes, je peux modifier des infos et les clients connectés au système sont rafraichis. Pour permettre d'avoir le même fonctionnement si la base est modifiée par un programme externe j'utilise un servlet qui vérifie la base et déclenche les rafraichissement chez les clients. La vérification en base consiste, pour le moment, à regarder une table. Si des lignes existent alors elles sont traitées et devraient ensuite être détruites ..... mais seul le refresh se fait correctement, pas la destruction. La persistence n'est plus accessible, l'entitymanagerfactory est détruit ....
Les logs montre des messages d'erreurs qui indiquent que l'instance d'application a été fermée etc ... je comprends pas trop
Voici une partie du Log
Code:
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
|
18 mai 2009 15:57:26 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 1531 ms
18 mai 2009 15:57:26 com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet <init>
INFO: GlassFish ARP available: false
18 mai 2009 15:57:26 com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet <init>
INFO: Jetty ARP available: false
18 mai 2009 15:57:26 com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet <init>
INFO: Adapting to Thread Blocking environment
18 mai 2009 15:57:27 org.apache.coyote.http11.Http11Protocol start
INFO: D�marrage de Coyote HTTP/1.1 sur http-8080
18 mai 2009 15:57:27 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
18 mai 2009 15:57:27 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16 config=null
18 mai 2009 15:57:27 org.apache.catalina.startup.Catalina start
INFO: Server startup in 3838 ms
18 mai 2009 15:57:30 org.apache.catalina.core.StandardContext reload
INFO: Le rechargement de ce contexte a d�marr�
18 mai 2009 15:57:30 org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing org.springframework.web.context.support.XmlWebApplicationContext@1a73d30: display name [Root WebApplicationContext]; startup date [Mon May 18 15:57:25 CEST 2009]; root of context hierarchy
18 mai 2009 15:57:30 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3acc67: defining beans [applicationContextHolder,renderManager,ApplicationBean1,SessionBean,PersonneBean,dataSource,dao,service,entityManagerFactory,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTransactionAdvisor,txManager,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0]; root of factory hierarchy
18 mai 2009 15:57:30 org.springframework.orm.jpa.AbstractEntityManagerFactoryBean destroy
INFO: Closing JPA EntityManagerFactory for persistence unit 'jpa'
18 mai 2009 15:57:30 org.hibernate.impl.SessionFactoryImpl close
INFO: closing |
Voici le code du timer
Code:
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
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package maj;
import aa.ApplicationContextHolder;
import com.icesoft.faces.async.render.RenderManager;
import java.util.Timer;
import java.util.TimerTask;
import org.springframework.context.ApplicationContext;
import service.IService;
import entites.LigneSuiviModifBDD;
import java.util.List;
public class synchro2 extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
private static Timer timer;
private TimerTaskTest task;
private int period=1000;
private ApplicationContext context;
private RenderManager renderManager;
private IService service;
static {
timer = new Timer("Test Timer");
}
public synchro2() {
super();
context = ApplicationContextHolder.getContext();
renderManager = (RenderManager) context.getBean("renderManager");
service= (IService) context.getBean("service");
task=new TimerTaskTest();
timer.schedule(task, 1000, period);
}
public void commit(){
/*Extraction des objets LigneSuiviModifBDD*/
List<LigneSuiviModifBDD> Resultat = service.extractionModifsBase();
for(LigneSuiviModifBDD uneLigneSuiviModifBDD : Resultat){
/*Generation des mises à jour via API Render pour chaque objet Ligne extait*/
String IDaRafraichir = uneLigneSuiviModifBDD.getnumeroId().toString();
renderManager.getOnDemandRenderer(IDaRafraichir).requestRender();
}
/*Destruction des lignes contenues dans Resultat*/
service.destructionModifsBase(Resultat);
}
class TimerTaskTest extends TimerTask{
public void run ( ){
try
{
commit();
}
catch ( Exception ee )
{
}
}
}
} |
Toute l'appli est configurée via le contexte Spring
Code:
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
|
<?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:p="http://www.springframework.org/schema/p"
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">
<!-- Bean d'acces au Contexte -->
<!-- Utilisé pour le sevlet synchro1 -->
<!-- voir : http://java.developpez.com/faq/spring/?page=bases#accesscontextfromnonspringbean -->
<bean id="applicationContextHolder" class="aa.ApplicationContextHolder" />
<bean id="renderManager" class="com.icesoft.faces.async.render.RenderManager" />
<bean id="ApplicationBean1" class="aa.ApplicationBean1" />
<bean id="SessionBean" class="aa.SessionBean" scope="session">
<property name="service" ref="service" />
<property name="renderManager" ref="renderManager" />
</bean>
<bean id="PersonneBean" class="aa.PersonneBean" scope="session">
<property name="service" ref="service" />
<property name="sessionEnCours" ref="SessionBean"/>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://localhost:3306/gipsi"
p:username="root"
p:password=""/>
<!-- couches applicatives -->
<bean id="dao" class="dao.Dao" />
<bean id="service" class="service.Service">
<property name="dao" ref="dao" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="generateDdl" value="true" />
</bean>
</property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
</bean>
<!-- le gestionnaire de transactions -->
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- traduction des exceptions -->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<!-- persistence -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
</beans> |
et enfin le Web.xml
Code:
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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">
<context-param>
<param-name>com.icesoft.faces.concurrentDOMViews</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.debugDOMUpdate</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.uploadMaxFileSize</param-name>
<param-value>4048576</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.standardRequestScope</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.synchronousUpdate</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Persistent Faces Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Blocking Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>uploadServlet</servlet-name>
<servlet-class>com.icesoft.faces.component.inputfile.FileUploadServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>synchro1</servlet-name>
<servlet-class>maj.synchro1</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>synchro2</servlet-name>
<servlet-class>maj.synchro2</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>*.iface</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Blocking Servlet</servlet-name>
<url-pattern>/block/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>uploadServlet</servlet-name>
<url-pattern>/uploadHtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>synchro1</servlet-name>
<url-pattern>/MAJ/synchro1</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app> |
Quelqu'un saurait-il m'expliquer d'où vient le problème ?
Merci d'avance pour votre aide.
le log de localhost de Tomcat
Un complément dans lequel on voit bien que l'application ferme...
Log de tomcat ( localhost)
Code:
1 2 3 4 5 6 7 8 9 10 11
|
18 mai 2009 17:03:42 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
18 mai 2009 17:03:44 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
18 mai 2009 17:03:44 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
18 mai 2009 17:03:48 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
18 mai 2009 17:03:53 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext |