Salut
Je développe une appli web avec :
Spring 3.1.2
Tomcat 6
JDK 7
SQL Serveur 2008 R2 (JDBC driver sqljdbc4.jar)
Tout marche bien.
Quand je passe du JDK 7 -> JDK 6, mon appli ne marche plus?:
Pourtant Spring n'a besoin que d'un JDK 1.5+.
Ça a l'air de venir de la partie base de données.
Quand je démarre Tomcat, aucune erreur sur la console.
Quand j'accède à l'application, mon navigateur reste bloqué sur "waiting for localhost".
En faisant du debug, j'ai identifié où ça coinçait :
J'ai mis un point d'arrêt dans la méthode isUrlProtected method, mais je ne l'atteins jamais.
Code : Sélectionner tout - Visualiser dans une fenêtre à part if (SpringHelper.getInstance(request).getUrlService().isUrlProtected(pUrl))
Quand je regarde le contenu de getUrlService(), je vois des choses bizarres :
Je n'arrive jamais à rentrer dans la méthode isUrlProtected, mon breakpoint n'est jamais atteint.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 CGLIB$BOUND true [...] CGLIB$CALLBACK_0 Cglib2AopProxy$DynamicAdvisedInterceptor (id=3121) iUrlDao null
Le thread Tomcat est marqué "running" mais aucune réponse n'a été envoyée au client (mon navigateur est toujours bloqué sur waiting for localhost).
Aucune trace d'erreur dans le console.
Ma couche service :
Ma couche DAO :
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 // imports [...] @Transactional public class ServiceUrl { private InterfaceTUrlDao iUrlDao; /** * @return the iUrlDao */ public InterfaceTUrlDao getiUrlDao() { return iUrlDao; } /** * @param iUrlDao the iUrlDao to set */ public void setiUrlDao(InterfaceTUrlDao iUrlDao) { this.iUrlDao = iUrlDao; } public void persist(TUrl transientInstance) { iUrlDao.persist(transientInstance); } public void remove(TUrl persistentInstance) { iUrlDao.remove(persistentInstance); } public TUrl merge(TUrl detachedInstance) { return iUrlDao.merge(detachedInstance); } public TUrl findById(int id) { return iUrlDao.findById(id); } public boolean isUrlProtected(String urlPath) { // just search for the entry in db return iUrlDao.findByPath(urlPath) != null; } }
Mon application-context.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 // imports [...] /** * Home object for domain model class TUrl. * @author Hibernate Tools */ public class TUrlDao implements InterfaceTUrlDao { private static final Log log = LogFactory.getLog(TUrlDao.class); @PersistenceContext(type=PersistenceContextType.EXTENDED) private EntityManager entityManager; public void persist(TUrl transientInstance) { log.debug("persisting TUrl instance"); try { entityManager.persist(transientInstance); log.debug("persist successful"); } catch (RuntimeException re) { log.error("persist failed", re); throw re; } } public void remove(TUrl persistentInstance) { log.debug("removing TUrl instance"); try { entityManager.remove(persistentInstance); log.debug("remove successful"); } catch (RuntimeException re) { log.error("remove failed", re); throw re; } } public TUrl merge(TUrl detachedInstance) { log.debug("merging TUrl instance"); try { TUrl result = entityManager.merge(detachedInstance); log.debug("merge successful"); return result; } catch (RuntimeException re) { log.error("merge failed", re); throw re; } } public TUrl findById(int id) { log.debug("getting TUrl instance with id: " + id); try { TUrl instance = entityManager.find(TUrl.class, id); entityManager.refresh(instance); log.debug("get successful"); return instance; } catch (RuntimeException re) { log.error("get failed", re); throw re; } } public TUrl findByPath(String path) { try { Query query = entityManager.createQuery("select u from TUrl u where u.pathUrl like :theUrl"); query.setParameter("theUrl", path); TUrl result = (TUrl) query.getSingleResult(); entityManager.refresh(result); return result; } catch (NoResultException nre) { return null; } catch (NonUniqueResultException nure) { throw nure; } } }
SpringHelper.java
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 <?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:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"> <!-- DAO layer --> <bean id="daoUrl" class="myProject.dao.jpa.TUrlDao" /> [...] <!-- Service layer --> <bean id="serviceUrl" class="myProject.service.ServiceUrl"> <property name="iUrlDao" ref="daoUrl"/> </bean> [...] <!-- Exception translation bean post processor --> <bean class="org.springframework.orm.hibernate3.HibernateExceptionTranslator"/> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> <!-- SQL Server data source --> <bean id="sqlServerDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /> <property name="url" value="jdbc:sqlserver://serverName:;databaseName=sid" /> <property name="username" value="user" /> <property name="password" value="pwd" /> </bean> <!-- entity manager --> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="sqlServerDataSource" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="false" /> <property name="databasePlatform" value="org.hibernate.dialect.SQLServer2008Dialect" /> <property name="generateDdl" value="false" /> </bean> </property> </bean> <!-- Transactions manager --> <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <!-- enable the configuration of transactional behavior based on annotations --> <tx:annotation-driven transaction-manager="txManager" /> <!-- Persistence --> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> <!-- Other data source not used currently... --> <bean id="oracleDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@server:1521:instance" /> <property name="username" value="user" /> <property name="password" value="pwd" /> </bean> <!-- Form validation : associated messages --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"> <value>messages</value> </property> </bean> </beans>
Quand je repasse du JDK 6 -> JDK 7, ça remarche.
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 // imports [...] /** * Spring Helper class. * * Provide access to bean objects defined in spring application context file. * * Based on Singleton pattern to initialize objects once. * */ public class SpringHelper { /** * Unique instance */ private static SpringHelper instance = null; /** * Service layer */ private ServiceUrl urlService; /** * @return the urlService */ public ServiceUrl getUrlService() { return urlService; } [...] /** * Singleton * */ public static SpringHelper getInstance(HttpServletRequest request) { // first call if (instance == null) { instance = new SpringHelper(request); } return instance; } /** * Private constructor to force Singleton usage */ private SpringHelper(HttpServletRequest request) { // get servlet context from request ServletContext servletContext = request.getSession().getServletContext(); // get service layer urlService = (ServiceUrl) WebApplicationContextUtils.getWebApplicationContext(servletContext).getBean("serviceUrl"); } }
Des pistes ? Je sèche...
Partager