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 :

[Spring 3.1] Spring + hibernate


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    230
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 230
    Par défaut [Spring 3.1] Spring + hibernate
    Bonjour,

    Je réalise un projet où j'utilise hibernate 3 + Spring 3.1(injection, gestion des transactions).

    Au départ, j'ai fait un simple projet Java "classique" avec les dao, services et les bons vieux tests unitaire avec un fichier de configuration Spring(applicationContext.xml) et lo4j.properties.
    tout marche bien comme il faut !!insertion, mise à jour, suppression des entités.

    C'est en fait, toute la couche basse de mon application.
    J'ai réalisé ensuite un jar de ce projet.
    Bien entendu, j'ai un projet, projet GWT qui a besoin de ce jar(couche basse de mon application) pour accéder à la base de données. Tout compile bien apparament qd mon projet GWT contient le jar que j'ai initalement créé...
    Les ennuis commencent....

    J'essaie de faire un pauvre test unit pour faire appel à un service de mon jar(=couche basse) dans le projet GWT (Projet GWT contient coucheBasse.jar=spring+hibernate)et là j'ai l'erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    17:55:52,381 ERROR HibernateUtil:73 - Problem reading file applicationContext.xml : org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    la ligne qui pose problème dans ma classe HibernateUtil est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    private final static String APPLICATION_CONTEXT_FILE="applicationContext.xml";
     
    ...
    private ApplicationContext ctx;
    ...
    ...
     
    this.ctx = new ClassPathXmlApplicationContext(HibernateUtil.APPLICATION_CONTEXT_FILE);
    En cherchant sur le net, pour ce type d'erreur, on trouve souvent la réponse qui dit :
    ajouter les jar manquant et particulièrement hibernate-validator.jar, un truc du style..
    Dans mon cas, cela ne tient pas car le même projet avec les mêmes librairies fonctionne trés bien seul.... j'en perds mon latin...

    merci d'avance pour votre aide, piste pour régler mon PROBLEME..

  2. #2
    Membre très actif
    Avatar de Khaled.Noordin
    Homme Profil pro
    Inscrit en
    Janvier 2005
    Messages
    354
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 354
    Billets dans le blog
    1
    Par défaut
    Salut
    ajoute ceci à ton pom qui est l’implémentation de bean validation par hibernate, à ta charge d'utiliser la version qui va bien avec ta version d'hibernate, sinon cet artifact va tirer une autre version de hibernate, à moins d'inclure une exclusion des artifacts ramenés par celui ci
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
      <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-validator</artifactId>
       <version>${hibernate-validator.version}</version>
      </dependency>
    Si tu n'utilise pas maven alors voici la page du projet ou tu trouvera un lien pour télécharger la bibliothèque en question hibernate-validator

    Cordialement Khaled.Noordin

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    230
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 230
    Par défaut
    je n'utilise pas maven pour le moment !cela devrait venir dans un futur proche...

    je vais essayer de rajouter ce jar à la mimine mais je ne comprends pas pourquoi dans le projet initial(couche basse), je n'ai pas ce jar et tout fonctionne correctement.

    Je me demande s'il arrive à trouver mon applicationContext.xml quand mon projet GWT possède le jar. Le fichier applicationContext.xml est resté bien entendu dans le jar que j'ai généré.
    Comment je peux m'assurer avec mon code que le fichier applicationContext.xml est bien trouvé ??

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    230
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 230
    Par défaut
    je viens de faire le test en rajoutant le validation-api-1.0.0.GA.jar(distribution 4.2) et cela n'a RIEN CHANGE...

    je ne vois pas trop d'où vient mon erreur ???

    toute aide, piste sont les bienvenues....
    merci

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    230
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 230
    Par défaut
    cette erreur me rend fou....

    Je me suis assuré que je lis bien le fichier applicationContext.xml(utile à Spring). Je me suis aperçu en scrutant les log de spring dans la console eclipse de chose bizarre par rapport à un fonctionnemment normal(=dans un projet classique Java que j'ai réalisé auparavant)
    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
     
     Creating shared instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    16:03:08,036 DEBUG DefaultListableBeanFactory:433 - Creating instance of bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    16:03:08,036 DEBUG InfrastructureAdvisorAutoProxyCreator:387 - Did not attempt to auto-proxy infrastructure class [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]
    16:03:08,038 DEBUG DefaultListableBeanFactory:507 - Eagerly caching bean 'org.springframework.transaction.config.internalTransactionAdvisor' to allow for resolving potential circular references
    16:03:08,038 DEBUG CachedIntrospectionResults:222 - Getting BeanInfo for class [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]
    16:03:08,043 DEBUG CachedIntrospectionResults:238 - Caching PropertyDescriptors for class [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]
    16:03:08,043 DEBUG CachedIntrospectionResults:250 - Found bean property 'advice' of type [org.aopalliance.aop.Advice]
    16:03:08,044 DEBUG CachedIntrospectionResults:250 - Found bean property 'adviceBeanName' of type [java.lang.String]
    16:03:08,044 DEBUG CachedIntrospectionResults:250 - Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory]
    16:03:08,044 DEBUG CachedIntrospectionResults:250 - Found bean property 'class' of type [java.lang.Class]
    16:03:08,044 DEBUG CachedIntrospectionResults:250 - Found bean property 'classFilter' of type [org.springframework.aop.ClassFilter]
    16:03:08,044 DEBUG CachedIntrospectionResults:250 - Found bean property 'order' of type [int]
    16:03:08,045 DEBUG CachedIntrospectionResults:250 - Found bean property 'perInstance' of type [boolean]
    16:03:08,045 DEBUG CachedIntrospectionResults:250 - Found bean property 'pointcut' of type [org.springframework.aop.Pointcut]
    16:03:08,045 DEBUG CachedIntrospectionResults:250 - Found bean property 'transactionAttributeSource' of type [org.springframework.transaction.interceptor.TransactionAttributeSource]
    d'habitude, je n'ai pas les lignes suivantes : Found bean property 'advice' of..etc...

    cette ligne , que je n'ai pas d'habitude d'avoir, me pose question :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Did not attempt to auto-proxy infrastructure class [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]
    ensuite pour finir, ces lignes me posent questions car je ne les ai pas d'habitude :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    16:03:08,215 DEBUG TypeConverterDelegate:380 - Converting String to [class java.lang.Class] using property editor [org.springframework.beans.propertyeditors.ClassEditor@6e8f94]
    16:03:08,218 DEBUG TypeConverterDelegate:380 - Converting String to [class java.lang.Class] using property editor [org.springframework.beans.propertyeditors.ClassEditor@6e8f94]
    16:03:08,218 DEBUG TypeConverterDelegate:380 - Converting String to [class java.lang.Class] using property editor [org.springframework.beans.propertyeditors.ClassEditor@6e8f94]
    16:03:08,219 DEBUG TypeConverterDelegate:380 - Converting String to [class java.lang.Class] using property editor [org.springframework.beans.propertyeditors.ClassEditor@6e8f94]
    16:03:08,220 DEBUG TypeConverterDelegate:380 - Converting String to [class java.lang.Class] using property editor [org.springframework.beans.propertyeditors.ClassEditor@6e8f94]
    16:03:08,221 DEBUG TypeConverterDelegate:380 - Converting String to [class java.lang.Class] using property editor [org.springframework.beans.propertyeditors.ClassEditor@6e8f94]
    16:03:08,221 DEBUG TypeConverterDelegate:380 - Converting String to [class java.lang.Class] using property editor [org.springframework.beans.propertyeditors.ClassEditor@6e8f94]
    si quelqu'un peut m'aider, donner une piste car je commence à tourner en rond???? je pense qu'il y a un petit truc qui cloche mais OU ???

    merci d'avance....

  6. #6
    Membre Expert
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 963
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 963
    Par défaut
    Une cause possible de problèmes "bizarres" est une incohérence dans les déclarations d'entête de l'applicationContext.xml : montrez le fichier complet.

Discussions similaires

  1. [Framework] Spring avec JSF et Hibernate
    Par wajdopovitch dans le forum Spring
    Réponses: 0
    Dernier message: 11/12/2009, 12h49
  2. [Data] [SPRING 2.5][JPA][Hibernate] Rollback
    Par hkefi dans le forum Spring
    Réponses: 8
    Dernier message: 30/12/2008, 15h15
  3. [Hibernate - Spring] Spring => Version 2 d'Hibernate?
    Par cicolas dans le forum Hibernate
    Réponses: 2
    Dernier message: 30/05/2006, 16h22

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