IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Comportement bizarre depuis passage JDK 7 -> JDK 6


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre habitué
    Homme Profil pro
    Inscrit en
    Novembre 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Novembre 2008
    Messages : 13
    Par défaut Comportement bizarre depuis passage JDK 7 -> JDK 6
    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 :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    if (SpringHelper.getInstance(request).getUrlService().isUrlProtected(pUrl))
    J'ai mis un point d'arrêt dans la méthode isUrlProtected method, mais je ne l'atteins jamais.

    Quand je regarde le contenu de getUrlService(), je vois des choses bizarres :

    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
    Je n'arrive jamais à rentrer dans la méthode isUrlProtected, mon breakpoint n'est jamais atteint.
    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 :
    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;
    	}
    }
    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
    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;
    		}
    	}
    }
    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
     
    <?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>
    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
     
    // 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");
    	}
    }
    Quand je repasse du JDK 6 -> JDK 7, ça remarche.

    Des pistes ? Je sèche...

  2. #2
    Membre éclairé Avatar de Jacobian
    Inscrit en
    Février 2008
    Messages
    425
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 425
    Par défaut
    comment tu fais pour recompiler en jdk 6 ?
    je crois que ton souci est juste tu n'a pas bien recompiler les sources

  3. #3
    Membre habitué
    Homme Profil pro
    Inscrit en
    Novembre 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Novembre 2008
    Messages : 13
    Par défaut
    Citation Envoyé par Jacobian Voir le message
    comment tu fais pour recompiler en jdk 6 ?
    je crois que ton souci est juste tu n'a pas bien recompiler les sources
    Sur le projet j'ai fait un clean + rebuild complet.

    Coté Tomcat, j'ai fais un clean + clean working directory.

  4. #4
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Quand tu met en pause ta jvm dans ton IDE, quel est le stacktrace de la requete en cours?

  5. #5
    Membre habitué
    Homme Profil pro
    Inscrit en
    Novembre 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Novembre 2008
    Messages : 13
    Par défaut
    Citation Envoyé par tchize_ Voir le message
    Quand tu met en pause ta jvm dans ton IDE, quel est le stacktrace de la requete en cours?
    Je n'ai aucune trace SQL car c'est la couche DAO appelée dans isUrlProtected qui fait la requête.

    Mon problème est justement que je n'arrive pas à rentrer dans cette fameuse méthode isUrlProtected.

    J'ai mis en pause sur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    if (SpringHelper.getInstance(request).getUrlService().isUrlProtected(pUrl))
    Je rentre dans getInstance et getUrlService mais pas dans isUrlProtected (c'est bien ça le problème).

  6. #6
    Membre éclairé Avatar de Jacobian
    Inscrit en
    Février 2008
    Messages
    425
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 425
    Par défaut
    met dans la condition true et laissé l'application tourné

  7. #7
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Citation Envoyé par schumi2k2 Voir le message
    Je n'ai aucune trace SQL
    J'ai parlé de la stacktrace. Qu'on sache exactement sur quel verrou bloque la jvm. T'accord, t'es à l'appel, d'accord tu n'es pas rentré dans le corps de ta méthode. Mais ton thread est coincé quelque par entre les deux, surement dans une méthode de CGLIB et on aimerais bien savoir laquelle => stacktrace.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [IO][Sérialisation]Exception bizarre depuis applet
    Par Pill_S dans le forum Applets
    Réponses: 8
    Dernier message: 15/12/2004, 19h08
  2. [ACESS][MEMO][ISNULL]Comportement bizarre
    Par seb.49 dans le forum ASP
    Réponses: 2
    Dernier message: 09/06/2004, 10h44
  3. [opentool][JDK]Changer le JDK d'un projet ss wizard
    Par Mobaladje dans le forum JBuilder
    Réponses: 8
    Dernier message: 03/05/2004, 14h37
  4. [HttpClient] comportement bizarre, saute des catch()...
    Par iubito dans le forum Développement Web en Java
    Réponses: 4
    Dernier message: 04/02/2004, 15h25
  5. [Sybase] Comportement bizarre d'une table
    Par sdozias dans le forum Sybase
    Réponses: 4
    Dernier message: 03/02/2004, 10h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo