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 :

Fichier configuration xml


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
    Avril 2006
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 197
    Par défaut Fichier configuration xml
    Slt à tous,

    J'essayer de faire un exo,en utilisant spring hibernate et jsf
    Le probléme que j'ai,c'est comment configurer les fichies web.xml et appcontext.xml
    Voici ceux que j'ai fait

    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
    53
     
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     
        <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>server</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>
     
        <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>contextConfigLocation</param-name>
            <param-value>/WEB-INF/*.xml</param-value>
        </context-param>
       
        <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>/faces/*</url-pattern>
        </servlet-mapping>
        
        <welcome-file-list>
            <welcome-file>faces/index.jsp</welcome-file>
        </welcome-file-list>
      
        <jsp-config>
            <jsp-property-group>
                <url-pattern>*.jspf</url-pattern>
                <is-xml>true</is-xml>
            </jsp-property-group>
        </jsp-config>
    </web-app>
    appcontext.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
     
    <?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: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.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
     
        <!-- service test --><!--setHibernateDao(de l'objet testHibernateDao)-->
        <bean id="springTestService" class="TestServiceImpl">
            <property name="hibernateDao" ref="testHibernateDao"/>
        </bean>
     
        <!-- hibernate dao --><!--setSessionFactory(de l'objet mysessionFactory)-->
        <bean id="testHibernateDao" class="TestHibernateDao">
            <property name="sessionFactory" ref="mySessionFactory" />
        </bean>
     
     
        <!-- configuration datasource & sessionFactory -->
        <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource">
                <ref bean ="myDataSource"/>
            </property>
            <property name="annotatedClasses">
                <list>
                    <value>Personne</value>
                </list>
            </property>
            <property name="hibernateProperties">
                <map>
                    <entry key="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
                    <entry key="hibernate.show_sql" value="true" />
                    <entry key="hibernate.hbm2ddl.auto" value="update" />
                </map>
            </property>
        </bean>
     
     
        <bean id="myDataSource"class="org.springframework.jdbc.dataSource.DriverManagerDataSource">
            <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
            <property name="url" value="jdbc:hsqldb:hsql://localhost/DB" />
            <property name="username" value="sa" />
            <property name="password" value="" />
        </bean>
     
    </beans>
    faceconfig.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
     
    <?xml version='1.0'?>
    <!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
     
    <faces-config>
     
        <managed-bean>
            <managed-bean-name>controleurpers</managed-bean-name>
            <managed-bean-class>ControleurPersonne</managed-bean-class>
            <managed-property>
                <property-name>springTestServive</property-name>
                <value>#{springTestService}</value>
            </managed-property>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
     
    </faces-config>
    Pour recuper l objet
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    public class ControleurPersonne {
     
        private UIOutput output;
        private Personne personne;
        private List PersonneItems = new ArrayList();
        private TestServiceImpl springTestService;//contient toutes les infos de connection
    l'erreur que j'ai
    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
     
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: javax.faces.FacesException: javax.faces.FacesException: Can't set managed bean property: 'springTestServive'.
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    	com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
    	com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
    	com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
    	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
    	com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
    	javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

  2. #2
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut
    quelle erreur tu as ?

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 197
    Par défaut
    j arrive pas corriger l erreur,si qu'elle qu'un peut m aider,j ai fais le code en haut...merci

  4. #4
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut
    springTestServive = springTestService

    corrige ton

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <managed-property>
                <property-name>springTestServive</property-name>
                <value>#{springTestService}</value>
            </managed-property>

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 197
    Par défaut
    merci mister,c'étais bien ca,encore une erreur de frappe grrrrr

    Encore une autre erreur,quand je rajoute ca dans le fichier web.xml

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
        <listener>
            <description>Spring context Loader listener</description>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>   
     
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/appContext.xml</param-value>
        </context-param>
    Il me dit qu'il n'arrive pas à deployer le war,ca vient du listener,il y a une librairie spécial à mettre?

  6. #6
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut
    il contient quoi ton repertoire lib

Discussions similaires

  1. problème d'accès à un fichier de configuration XML
    Par yeddoughmi dans le forum Autres
    Réponses: 1
    Dernier message: 30/05/2007, 20h53
  2. Configuration du fichier Web.xml
    Par bulatovic dans le forum Struts 1
    Réponses: 14
    Dernier message: 10/03/2007, 15h22
  3. Configurer des paramétres dans le fichier server.xml
    Par root76 dans le forum Tomcat et TomEE
    Réponses: 1
    Dernier message: 13/02/2007, 17h16
  4. [Hibernate]probleme fichier de configuration xml
    Par scoryo dans le forum Hibernate
    Réponses: 4
    Dernier message: 07/06/2006, 18h42
  5. Réponses: 3
    Dernier message: 04/02/2006, 09h49

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