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 Web Java Discussion :

J2EE Spring - Annotations non prises en compte


Sujet :

Spring Web Java

  1. #1
    Candidat au Club
    Homme Profil pro
    Ingénieur logiciel (WinDev)
    Inscrit en
    Juillet 2014
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Tarn (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur logiciel (WinDev)
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 6
    Points : 3
    Points
    3
    Par défaut J2EE Spring - Annotations non prises en compte
    Bonsoir amis développeurs,

    (Contexte - Vous pouvez vous rediriger vers la section Demande si vous ne souhaitez pas perdre de temps.)
    Récemment, j'ai suivi de nombreux tutoriels pour me lancer dans la création d'un site internet en J2EE.
    Basée sur les Frameworks Spring, Hibernate et Primefaces, l'application évolue lentement mais sûrement...
    C'est alors que j'ai été confronté à l'utilisation des annotations avec Spring.
    J'ai vu de nombreux sujets sur le forum developpez.net qui parlaient de ses fameuses annotations, et ai pu rectifier quelques erreurs.
    Typiquement, je n'avais pas activé la gestion des annotations dans Spring.
    Malgré le parcours de X tutoriels sur Spring, je ne parviens toujours pas à faire fonctionner les annotations d'injection.
    J'ai ajouté ces deux lignes dans le fichier de configuration de Spring (applicationContext.xml) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <context:component-scan base-package="com.mickaelcalmettes.siteweb" />
    <context:annotation-config />
    Je n'ai pas déclaré ces balises ailleurs (car apparemment cela pose problème de scanner plusieurs fois le projet).

    (Demande)
    Concrètement, j'ai annoté tous mes DAOImpl avec l'annotation @Repository("nomDuDAO"), tous mes ServiceImpl avec l'annotation @Service("nomDuService"), et toutes mes références aux IDAO et IServices avec @Autowired.
    J'ai créé un backing bean qui appelle un service de test, et lors de cet appel, je reçois un NullPointerException.
    Les détails ci-après.

    (Informations sur le code)
    La vue :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <h:commandButton value="Test création catégorie avec todos inexistants" action="#{testHibernateBean.creerCategorie()}" />
    <h:commandButton value="Test création todo avec une catégorie inexistante" action="#{testHibernateBean.creerTodo()}" />
    Ces boutons appelent le backingBean "TestHibernateBean" :
    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
    86
    87
    88
    89
    90
    91
    92
    @ManagedBean(name = "testHibernateBean")
    @ViewScoped
    public class TestHibernateBean implements Serializable {
        private Categorie categorie1;
        private final Set<TodoMemo> todoSet = new HashSet();
        private TodoMemo todo;
        private Categorie categorie2;
        @Autowired
        private ITodoService todoService;
        @Autowired
        private ICategorieService categorieService;
     
        @PostConstruct
        public void init() {
            this.initTests();
        }
     
        private void initTests() {
            // Création du jeu de données
            categorie1 = new Categorie();
            categorie2 = new Categorie();
            categorie1.setLibelleCategorie("Catégorie avec plusieurs TODO");
            categorie2.setLibelleCategorie("Catégorie avec un seul TODO");
            todo = new TodoMemo();
            todo.setDateTodo(new Date());
            todo.setPriorite(5);
            todo.setTodo("Todo relié à la catégorie 'Catégorie avec un seul TODO'");
            for(int i=1 ; i<5 ; i++){
                TodoMemo tempTodo = new TodoMemo();
                tempTodo.setDateTodo(new Date());
                tempTodo.setPriorite(i);
                tempTodo.setTodo("Todo relié à la catégorie 'Catégorie avec plusieurs TODO' n°" + i);
                todoSet.add(tempTodo);
            }
     
            // Liaisons
            categorie1.setTodo(todoSet);
            todo.setCategorie(categorie2);
        }
     
        public void creerCategorie(){
            // Test création catégorie avec plusieurs TODO associés
            categorieService.saveCategorie(categorie1);
        }
     
        public void creerTodo(){
            // Test création todo avec catégorie associée
            todoService.saveTodo(todo);
        }
     
        public Categorie getCategorie1() {
            return categorie1;
        }
     
        public void setCategorie1(Categorie categorie1) {
            this.categorie1 = categorie1;
        }
     
        public TodoMemo getTodo() {
            return todo;
        }
     
        public void setTodo(TodoMemo todo) {
            this.todo = todo;
        }
     
        public Categorie getCategorie2() {
            return categorie2;
        }
     
        public void setCategorie2(Categorie categorie2) {
            this.categorie2 = categorie2;
        }
     
        public ITodoService getTodoService() {
            return todoService;
        }
     
        public void setTodoService(ITodoService todoService) {
            this.todoService = todoService;
        }
     
        public ICategorieService getCategorieService() {
            return categorieService;
        }
     
        public void setCategorieService(ICategorieService categorieService) {
            this.categorieService = categorieService;
        }
     
     
    }
    Lors de l'appel de l'une des deux méthodes creerCategorie() ou creerTodo(), Spring ne parvient pas à retrouver le service appelé malgré les annotations.
    Il me génère un NullPointerException (au besoin je peux insérer la trace de l'erreur). J'ai testé d'appeler le service via le service implémenté (CategorieServiceImpl par exemple), et il n'y a plus d'erreur. Enfin, si, mais le NullPointerException se génère dans le service lors de l'appel du DAO.

    Voici l'interface du service "ICategorieService" :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    public interface ICategorieService {
        public void saveCategorie(Categorie categorie);
    }
    Voici le service "CategorieServiceImpl" qui devrait être appelé par Spring grâce aux annotations :
    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
    @Service("categorieService")
    public class CategorieServiceImpl implements ICategorieService {
     
        @Autowired
        ICategorieDAO categorieDAO;
     
        @Override
        public void saveCategorie(Categorie categorie) {
            categorieDAO.saveCategorie(categorie);
        }
     
        public ICategorieDAO getCategorieDAO() {
            return categorieDAO;
        }
     
        public void setCategorieDAO(ICategorieDAO categorieDAO) {
            this.categorieDAO = categorieDAO;
        }
     
    }
    Et enfin, voici les fichiers de configuration.
    "applicationContext.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
    <?xml version='1.0' encoding='UTF-8' ?>
    <!-- was: <?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:context="http://www.springframework.org/schema/context"
     
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context.xsd
        ">
     
        <context:component-scan base-package="com.mickaelcalmettes.siteweb" />
        <context:annotation-config />
     
    <!--    <bean id="categorieDAO" class="com.mickaelcalmettes.siteweb.dao.impl.CategorieDAOImpl" />
        <bean id="todoDAO" class="com.mickaelcalmettes.siteweb.dao.impl.TodoDAOImpl" />
        <bean id="categorieService" class="com.mickaelcalmettes.siteweb.services.impl.CategorieServiceImpl" />
        <bean id="todoService" class="com.mickaelcalmettes.siteweb.services.impl.TodoServiceImpl" />-->
     
    </beans>
    "dispatcher-servlet.xml" : Je ne me sers pas de ce fichier de configuration, il a été créé automatiquement par Netbeans. Je peux fournir le code au besoin.

    "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
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>
        <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>
        <context-param>
            <param-name>CONFIG_PATH</param-name>
            <param-value>/WEB-INF</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>2</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-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>*.*</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>Pages/Tests/pageTestTemplateAccueil.xhtml</welcome-file>
        </welcome-file-list>
    </web-app>
    Merci beaucoup par avance de votre aide.
    Je m'excuse de la longueur du message, je tenais à le rendre le plus clair possible.
    En vous souhaitant une agréable soirée,
    M20K8X.

  2. #2
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    ceci tu le mets dans ton dispatcher-servlet.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <context:component-scan base-package="com.mickaelcalmettes.siteweb" />
    Eric

  3. #3
    Candidat au Club
    Homme Profil pro
    Ingénieur logiciel (WinDev)
    Inscrit en
    Juillet 2014
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Tarn (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur logiciel (WinDev)
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 6
    Points : 3
    Points
    3
    Par défaut
    Bonjour Eric,

    Je te remercie de ton aide.
    Cependant, l'erreur persiste et n'a pas changé malgré le déplacement du scan des beans depuis le fichier applicationContext.xml vers le fichier dispatcher-servlet.xml.

    applicationContext.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
    <?xml version='1.0' encoding='UTF-8' ?>
    <!-- was: <?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:context="http://www.springframework.org/schema/context"
     
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context.xsd
        ">
     
        <context:annotation-config />
     
    <!--    <bean id="categorieDAO" class="com.mickaelcalmettes.siteweb.dao.impl.CategorieDAOImpl" />
        <bean id="todoDAO" class="com.mickaelcalmettes.siteweb.dao.impl.TodoDAOImpl" />
        <bean id="categorieService" class="com.mickaelcalmettes.siteweb.services.impl.CategorieServiceImpl" />
        <bean id="todoService" class="com.mickaelcalmettes.siteweb.services.impl.TodoServiceImpl" />-->
     
    </beans>
    dispatcher-servler.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
    <?xml version='1.0' encoding='UTF-8' ?>
    <!-- was: <?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:context="http://www.springframework.org/schema/context"
     
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context.xsd
        ">
     
        <!--<mvc:resources mapping="/resources/**" location="/resources/mytheme/" />-->
    <!--    <context:component-scan base-package="com.mickaelcalmettes.siteweb" />
        <context:annotation-config />-->
        <context:component-scan base-package="com.mickaelcalmettes.siteweb" />
     
        <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
            <property name="locations">
                <list>
                    <!--<value>file:${CONFIG_PATH}/Messages.properties</value>-->
                    <value>classpath:Messages.properties</value>
                </list>
            </property>
        </bean> 
     
        <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
        <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="index.htm">indexController</prop>
                </props>
            </property>
        </bean>
     
        <bean id="viewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver"
              p:prefix="/WEB-INF/jsp/"
              p:suffix=".jsp" />
     
        <!--
        The index controller.
        -->
        <bean name="indexController"
              class="org.springframework.web.servlet.mvc.ParameterizableViewController"
              p:viewName="index" />
     
    </beans>
    C'est tout de même étrange...
    A priori les annotations ne sont pas trop mauvaises puisque beaucoup de personnes procèdent comme ceci, et normalement Spring a activé les annotations et scanné mes beans stéréotypés...

    Le message d'erreur si cela peut aider :
    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
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    03-Jul-2014 17:35:55.092 WARNING [http-nio-8084-exec-10] com.sun.faces.lifecycle.InvokeApplicationPhase.execute #{testHibernateBean.creerCategorie()}: java.lang.NullPointerException
     javax.faces.FacesException: #{testHibernateBean.creerCategorie()}: java.lang.NullPointerException
    	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
    	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
    	at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
    	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575)
    	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
    	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
    	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    	... 31 more
    Caused by: java.lang.NullPointerException
    	at com.mickaelcalmettes.siteweb.beans.tests.TestHibernateBean.creerCategorie(TestHibernateBean.java:63)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:483)
    	at org.apache.el.parser.AstValue.invoke(AstValue.java:261)
    	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:277)
    	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
    	... 32 more
     
    03-Jul-2014 17:35:55.232 1100 [http-nio-8084-exec-10] com.sun.faces.context.ExceptionHandlerImpl.log JSF1073 : javax.faces.FacesException intercepté durant le traitement de INVOKE_APPLICATION 5 : UIComponent-ClientId=, Message=#{testHibernateBean.creerCategorie()}: java.lang.NullPointerException
    03-Jul-2014 17:35:55.232 1100 [http-nio-8084-exec-10] com.sun.faces.context.ExceptionHandlerImpl.log #{testHibernateBean.creerCategorie()}: java.lang.NullPointerException
     javax.faces.FacesException: #{testHibernateBean.creerCategorie()}: java.lang.NullPointerException
    	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:89)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
    	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
    	at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
    	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575)
    	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: javax.faces.FacesException: #{testHibernateBean.creerCategorie()}: java.lang.NullPointerException
    	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    	... 27 more
    Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
    	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
    	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    	... 31 more
    Caused by: java.lang.NullPointerException
    	at com.mickaelcalmettes.siteweb.beans.tests.TestHibernateBean.creerCategorie(TestHibernateBean.java:63)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:483)
    	at org.apache.el.parser.AstValue.invoke(AstValue.java:261)
    	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:277)
    	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
    	... 32 more
    Dans le pire des cas je pourrai enlever Spring du projet et ne plus passer par des interfaces.
    Merci encore pour l'aide.

    En vous souhaitant une agréable fin de journée,
    M20K8X.

  4. #4
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    dans quels packages sont declarées tes classes?

  5. #5
    Candidat au Club
    Homme Profil pro
    Ingénieur logiciel (WinDev)
    Inscrit en
    Juillet 2014
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Tarn (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur logiciel (WinDev)
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 6
    Points : 3
    Points
    3
    Par défaut
    Bonsoir Eric,

    Voici l'arborescence de mon projet :
    Nom : arborescenceClasspath.png
Affichages : 378
Taille : 20,5 Ko

    Mes classes sont bien présentes dans un des sous-packages de "com.mickaelcalmettes.siteweb"...

    Point très intéressant !!! J'ai donc fait des tests en changeant l'emplacement du scan de packages, et je suis arrivé à un résultat très concluant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.mickaelcalmettes.siteweb.dao.ICategorieDAO com.mickaelcalmettes.siteweb.services.impl.CategorieServiceImpl.categorieDAO
    Cette erreur est normale, puisque je disais à Spring dans le test en question de scanner le sous-package "services". Pourquoi est-ce intéressant ? Parce que cela signifie que les annotations de Spring sont bien prises en compte ! Si je n'ai pas d'erreurs en temps normal, c'est que Spring arrive probablement à "Autowired" les beans...
    Donc déjà une partie du problème écartée : Spring annote bien les beans. Reste à savoir pourquoi alors il génère un NullPointerException quand je tente d'appeler un service ou un DAO en passant par l'interface...

    Merci Eric, ton post a déjà un peu éclairci le problème : Spring semble bien charger les beans !

    Passe une agréable soirée,
    M20K8X.

  6. #6
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    peux-tu nous montrer comment tu as implementé CategorieDAOImpl?

    eric

  7. #7
    Candidat au Club
    Homme Profil pro
    Ingénieur logiciel (WinDev)
    Inscrit en
    Juillet 2014
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Tarn (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur logiciel (WinDev)
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 6
    Points : 3
    Points
    3
    Par défaut
    Bonjour Eric,

    L'erreur que j'ai postée ci-dessus est seulement issue d'un test lorsque j'ai changé le contenu de la balise <context:component-scan base-package="com.mickaelcalmettes.siteweb" /> par <context:component-scan base-package="com.mickaelcalmettes.siteweb.service" />.
    En remettant <context:component-scan base-package="com.mickaelcalmettes.siteweb" /> je n'ai pas cette erreur.

    Actuellement, et d'après ces tests, les beans sont bien chargés par Spring (sinon il m'aurait mis une erreur pour Autowired comme dans le test ci-dessus !). Le NullPointerException intervient lorsque j'essaie d'appeler le service via TestHibernateBean :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    categorieService.saveCategorie(categorie1);
    Je l'ai déclaré ainsi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    @Autowired
        private ICategorieService categorieService;
    J'ai bien intégré le getter et le setter :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
        public ICategorieService getCategorieService() {
            return categorieService;
        }
     
        public void setCategorieService(ICategorieService categorieService) {
            this.categorieService = categorieService;
        }
    Il y a peut-être autre chose à faire que j'ai oublié ?

    PS : Je peux quand même poster le code du DAOImpl qui est tout bête, mais pour l'instant l'erreur se produit déjà lors de l'appel du 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
    package com.mickaelcalmettes.siteweb.dao.impl;
     
    import com.mickaelcalmettes.siteweb.dao.ICategorieDAO;
    import com.mickaelcalmettes.siteweb.entites.Categorie;
    import com.mickaelcalmettes.siteweb.utilitaires.HibernateUtil;
    import org.hibernate.Session;
    import org.springframework.stereotype.Repository;
     
    /**
     *
     * @author Mycky
     */
    @Repository("categorieDAO")
    public class CategorieDAOImpl implements ICategorieDAO {
     
        @Override
        public void saveCategorie(Categorie categorie) {
            Session session = HibernateUtil.getSessionFactory().getCurrentSession();
            session.beginTransaction();
            session.save(categorie);
            session.getTransaction().commit();
        }
     
    }
    EDIT : J'ai vérifié que l'objet "categorie1" passé ne soit pas nul, et il ne l'est pas donc l'erreur vient bien de l'appel du service.
    Je suis en train de créer un nouveau projet pour tester si j'ai encore le problème : même erreur

    Je crois que j'ai tout testé là... @Qualifier, default-autowire = "byName", etc. j'ai passé tous les forums possibles, je ne vois toujours pas pourquoi. Damn, c'est décidé, je vais me pendre.

    Passe une agréable journée et merci pour tes réponses,
    M20K8X.

  8. #8
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    ajoute l´annotation:
    sur ta classe :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    @Repository
    public class CategorieDAOImpl implements ICategorieDAO
    eric

  9. #9
    Candidat au Club
    Homme Profil pro
    Ingénieur logiciel (WinDev)
    Inscrit en
    Juillet 2014
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Tarn (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur logiciel (WinDev)
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 6
    Points : 3
    Points
    3
    Par défaut
    Bonsoir Eric,

    La classe est déjà stéréotypée en tant que Repository, cf. ci-dessous :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    @Repository("categorieDAO")
    public class CategorieDAOImpl implements ICategorieDAO {
    J'ai essayé également en enlevant "categorieDAO" (idem pour les services) mais ça ne change rien :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    @Repository
    public class CategorieDAOImpl implements ICategorieDAO {
    J'ai finalement continué l'application sans utiliser Spring, lorsque j'aurai un peu plus d'expérience, je tenterai de trouver l'erreur et d'aider les autres qui ont des problèmes. Je te remercie pour ton aide en tous cas.

  10. #10
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    Salut,
    j´ai refait tout ton projet en utilisant comme base de données SQLite, et cela fonctionne tres bien,
    j´avoue qu´il ya quelques configurations a faire mais le chemin que tu as pris est le bon.
    envoies moi un message en PN, et je t´enverrais la source de mon projet realise a base du tien.

    Eric

  11. #11
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    tu dois mettre:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    @Service
    public class TodoServiceImpl implements ITodoService {
    .....
    }
    puis
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    @Service("categorieService")
    public class CategorieServiceImpl implements ICategorieService {
    ....
    }
    et
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    @Repository
    public class CategorieDAOImpl implements ICategorieDAO {
    ...
    }
    et
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    @ManagedBean
    @RequestScoped
    @Component
    public class TestHibernateBean implements Serializable {
    ....
    }
    configuration:
    applicationContext.xml situé dans WEB-INF
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <context:component-scan base-package="com.mickaelcalmettes"/>
    dispatcher-servlet.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
     
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
     
    </beans>
    faces-config.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config
        xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
        version="2.2">
    <application>
            <el-resolver>
                    org.springframework.web.jsf.el.SpringBeanFacesELResolver
            </el-resolver>
        </application>
    </faces-config>
    et 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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="3.0" 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_3_0.xsd">
    	<display-name>M20K8X_Project</display-name>
     
    	<!-- The welcome page -->
    	<welcome-file-list>
    		<welcome-file>index.xhtml</welcome-file>
    	</welcome-file-list>
     
    	<!-- Spring listeners -->
    	 <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>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
      </servlet-mapping>
     
     
     
    </web-app>
    et si tu as des soucis au niveau des fichiers Jar, fais nous signe, car il ya parfois du superflue.

    bonne journée

    Eric

  12. #12
    Candidat au Club
    Homme Profil pro
    Ingénieur logiciel (WinDev)
    Inscrit en
    Juillet 2014
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Tarn (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur logiciel (WinDev)
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 6
    Points : 3
    Points
    3
    Par défaut
    Bonsoir Eric !

    Je ne saurais comment te remercier... Tu as résolu mon problème !!!
    Dans ton 2e message avec les différents bouts de code, tu as mis "faces-config.xml".
    Or, sur les tutoriels que j'ai suivis, ils ne mentionnaient pas ce fichier de configuration, ils ne mentionnaient que les fichiers web.xml, dispatcher-servlet.xml et applicationConfig.xml. Je n'avais donc le fichier faces-config.xml présent dans le répertoire WEB-INF !!
    En le créant avec le code que tu m'as fourni, et en ajoutant l'entrée suivante dans le fichier web.xml :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <context-param>
            <param-name>javax.faces.CONFIG_FILES</param-name>
            <param-value>/WEB-INF/faces-config.xml</param-value>
        </context-param>
    Toutes les annotations Spring sont passées et tout, absolument TOUT marche !!!

    Vraiment, merci infiniment Eric pour ton aide et le temps que tu as consacré pour m'aider !!
    Tu as trouvé la solution en proposant ce fichier de configuration !

    Pour ceux dans le même problème, voici la configuration finale de tous les fichiers de configuration :
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>
        <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>
        <context-param>
            <param-name>CONFIG_PATH</param-name>
            <param-value>/WEB-INF</param-value>
        </context-param>
        <context-param>
            <param-name>javax.faces.CONFIG_FILES</param-name>
            <param-value>/WEB-INF/faces-config.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>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>2</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-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>*.*</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>Pages/Tests/pageTestTemplateAccueil.xhtml</welcome-file>
        </welcome-file-list>
    </web-app>
    dispatcher-servlet.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
    <?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:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:tx="http://www.springframework.org/schema/tx"
     
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-4.0.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        ">   
     
        <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
            <property name="locations">
                <list>
                    <!--<value>file:${CONFIG_PATH}/Messages.properties</value>-->
                    <value>classpath:Messages.properties</value>
                </list>
            </property>
        </bean>
     
    </beans>
    applicationContext.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
    <?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:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:tx="http://www.springframework.org/schema/tx"
     
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-4.0.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        ">
     
        <context:component-scan base-package="com.mickaelcalmettes" />
     
    <!--    <bean id="categorieDAO" class="com.mickaelcalmettes.siteweb.dao.impl.CategorieDAOImpl" />
        <bean id="todoDAO" class="com.mickaelcalmettes.siteweb.dao.impl.TodoDAOImpl" />
        <bean id="categorieService" class="com.mickaelcalmettes.siteweb.services.impl.CategorieServiceImpl" />
        <bean id="todoService" class="com.mickaelcalmettes.siteweb.services.impl.TodoServiceImpl" />-->
     
    </beans>
    facesConfig.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
    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config
        xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
            http://xmlns.jcp.org/xml/ns/javaee
            http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd
        "
        version="2.2">
     
        <application>
            <el-resolver>
                    org.springframework.web.jsf.el.SpringBeanFacesELResolver
            </el-resolver>
        </application>
    </faces-config>
    Sytem.out.println("Merci beaucoup Eric !")

    En te souhaitant un agréable week-end,
    M20K8X.

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

Discussions similaires

  1. [Data] [Spring][Ibatis] transactions non prise en compte
    Par nannous dans le forum Spring
    Réponses: 15
    Dernier message: 27/11/2007, 19h01
  2. Installation SP2 + RAM non prise en compte
    Par laure_belette dans le forum Windows XP
    Réponses: 3
    Dernier message: 13/10/2005, 13h46
  3. [css] Feuille de style non prise en compte
    Par Neuromancien2 dans le forum Mise en page CSS
    Réponses: 4
    Dernier message: 29/06/2005, 12h49
  4. [netbeans] Modifications non prises en compte
    Par nadass dans le forum NetBeans
    Réponses: 6
    Dernier message: 07/04/2005, 14h49
  5. Lecture de fichier - dernière ligne non prise en compte
    Par JulienPles dans le forum Algorithmes et structures de données
    Réponses: 3
    Dernier message: 16/03/2005, 12h57

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