Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Hibernate/Spring SessionFactory

  1. #11
    Join Date
    Jun 2007
    Location
    Marseille - France
    Posts
    78

    Default

    hi mdeinum,
    you are right, I think that I have done an inopportune copy past.
    thanks

  2. #12
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    mdeinum:
    You can define a bean inside another bean, sometimes this is even prefered instead of defining 2 separate beans.
    can you tell me in which cases???

    Esil2008:
    is this resolved?

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #13
    Join Date
    Jun 2007
    Location
    Marseille - France
    Posts
    78

    Default

    no, i have an other error

    Code:
    ERROR [http-8081-Processor25] - Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'service' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'myPersonneDao' of bean class [istia.st.springmvc.personnes.service.ServiceImpl]: Bean property 'myPersonneDao' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    org.springframework.beans.NotWritablePropertyException: Invalid property 'myPersonneDao' of bean class [istia.st.springmvc.personnes.service.ServiceImpl]: Bean property 'myPersonneDao' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:670)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:572)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:737)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:764)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:753)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1057)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:378)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:283)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
    	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:519)
    	at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1220)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:457)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(Unknown Source)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(Unknown Source)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
    	at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1397)
    	at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:815)
    	at org.apache.catalina.manager.HTMLManagerServlet.deployInternal(HTMLManagerServlet.java:249)
    	at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:96)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    	at java.lang.Thread.run(Unknown Source)
     INFO [http-8081-Processor25] - Closing Spring root WebApplicationContext
    my applicationContext.xml now is :

    Code:
    <!DOCTYPE beans PUBLIC 	"-//SPRING//DTD BEAN//EN" 
    	"http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>	
    
    	<bean id="dataSource" 
    		  class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
    		<property name="driverClassName">
    			<value>com.mysql.jdbc.Driver</value>
    		</property>
    		<property name="url">
    			<value>jdbc:mysql://localhost/dbpersonnes</value>
    		</property>
    		<property name="username"><value>root</value></property>
    		<property name="password"><value></value></property>
    	</bean>
    
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref local="dataSource"/>
    		</property>
    		<property name="mappingResources">
    		<list>
    			<value>Personnes.hbm.xml</value>
    		</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">
    					org.hibernate.dialect.MySQLDialect
    				</prop>
    				<prop key="hbm2java">update</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<bean id="myTransactionManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager">
           <property name="sessionFactory">
       		<ref local="sessionFactory"/>
    		</property>
        </bean>
        
        <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
             <property name="sessionFactory">
               <ref bean="sessionFactory"/>
             </property>
        </bean>    
      	
      	<bean id="myPersonneDao" class="istia.st.springmvc.personnes.dao.DaoImplCommon">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    	
    	<bean id="service" class="istia.st.springmvc.personnes.service.ServiceImpl" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
    	<property name="myPersonneDao">
      	<ref local="myPersonneDao" /> 
      	</property>
      	</bean>
      	
    </beans>

  4. #14
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    ok

    in you class ServiceImpl

    is there the variable myPersonneDao and its set property?

    pls shown your code

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  5. #15
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    can you tell me in which cases???
    Sure.

    If you are defining ProxyFactoryBeans for instance, it is prefered to specify the target as an anonymous inner class. That way you prevent users from grabbing that bean and bypass the proxied instance.

    Code:
    org.springframework.beans.NotWritablePropertyException: Invalid property 'myPersonneDao' of bean class [istia.st.springmvc.personnes.service.ServiceImpl]: Bean property 'myPersonneDao' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    This errror indicates that you are trying to inject something but don't have a setter for it.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #16
    Join Date
    Jun 2007
    Location
    Marseille - France
    Posts
    78

    Default

    hi,

    no i dont have this variable

    the class ServiceImpl :
    Code:
    package istia.st.springmvc.personnes.service;
    
    import istia.st.springmvc.personnes.entites.Personne;
    import istia.st.springmvc.personnes.hibernate.Personnes;
    import istia.st.springmvc.personnes.dao.IDao;
    
    import java.util.Collection;
    import java.util.List;
    
    
    public class ServiceImpl implements IService {
    
    	// la couche [dao]
    	private IDao dao;
    
    	public IDao getDao() {
    		return dao;
    	}
    
    	public void setDao(IDao dao) {
    		this.dao = dao;
    	}
    
    	// liste des personnes
    	public List getAll() {
    		return dao.getAll();
    	}
    
    	// obtenir une personne en particulier
    	public Personnes getOne(int id) {
    		return dao.getOne(id);
    	}
    
    	// ajouter ou modifier une personne
    	public void saveOne(Personnes personne) {
    		dao.saveOne(personne);
    	}
    
    	// suppression d'une personne
    	public void deleteOne(int id) {
    		dao.deleteOne(id);
    	}
    
    	// sauvegarder une collection de personnes
    	public void saveMany(Personnes[] personnes) {
    		// on boucle sur le tableau des personnes
    		for (int i = 0; i < personnes.length; i++) {
    			dao.saveOne(personnes[i]);
    		}
    	}
    
    	// supprimer une collection de personnes
    	public void deleteMany(int[] ids) {
    		// ids : les id des personnes à supprimer
    		for (int i = 0; i < ids.length; i++) {
    			dao.deleteOne(ids[i]);
    		}
    	}
    }
    and the interface :
    Code:
    package istia.st.springmvc.personnes.service;
    
    import istia.st.springmvc.personnes.entites.Personne;
    import istia.st.springmvc.personnes.hibernate.Personnes;
    
    import java.util.Collection;
    import java.util.List;
    
    public interface IService {
    	// liste de toutes les personnes
    	List getAll();
    
    	// obtenir une personne particulière
    	Personnes getOne(int id);
    
    	// ajouter/modifier une personne
    	void saveOne(Personnes personne);
    
    	// supprimer une personne
    	void deleteOne(int id);
    
    	// ajouter plusieurs personnes
    	void saveMany(Personnes[] personnes);
    
    	// supprimer plusieurs personnes
    	void deleteMany(int ids[]);
    }
    thank you very much

  7. #17
    Join Date
    Jun 2007
    Location
    Marseille - France
    Posts
    78

    Default

    and the class personne who are generated automaticlly by middelgen is :
    Code:
    package istia.st.springmvc.personnes.hibernate;
    
    import java.io.Serializable;
    import java.util.Date;
    import org.apache.commons.lang.builder.ToStringBuilder;
    
    
    /** @author Hibernate CodeGenerator */
    public class Personnes implements Serializable {
    
        /** identifier field */
        private Integer Id;
    
        /** nullable persistent field */
        private Integer Version;
    
        /** nullable persistent field */
        private Date Datenaissance;
    
        /** nullable persistent field */
        private String Nom;
    
        /** nullable persistent field */
        private String Prenom;
    
        /** nullable persistent field */
        private Integer Nbenfants;
    
        /** nullable persistent field */
        private Integer Marie;
    
        /** full constructor */
        public Personnes(Integer Version, Date Datenaissance, String Nom, String Prenom, Integer Nbenfants, Integer Marie) {
            this.Version = Version;
            this.Datenaissance = Datenaissance;
            this.Nom = Nom;
            this.Prenom = Prenom;
            this.Nbenfants = Nbenfants;
            this.Marie = Marie;
        }
    
        /** default constructor */
        public Personnes() {
        }
    
        public Integer getId() {
            return this.Id;
        }
    
        public void setId(Integer Id) {
            this.Id = Id;
        }
    
        public Integer getVersion() {
            return this.Version;
        }
    
        public void setVersion(Integer Version) {
            this.Version = Version;
        }
    
        public Date getDatenaissance() {
            return this.Datenaissance;
        }
    
        public void setDatenaissance(Date Datenaissance) {
            this.Datenaissance = Datenaissance;
        }
    
        public String getNom() {
            return this.Nom;
        }
    
        public void setNom(String Nom) {
            this.Nom = Nom;
        }
    
        public String getPrenom() {
            return this.Prenom;
        }
    
        public void setPrenom(String Prenom) {
            this.Prenom = Prenom;
        }
    
        public Integer getNbenfants() {
            return this.Nbenfants;
        }
    
        public void setNbenfants(Integer Nbenfants) {
            this.Nbenfants = Nbenfants;
        }
    
        public Integer getMarie() {
            return this.Marie;
        }
    
        public void setMarie(Integer Marie) {
            this.Marie = Marie;
        }
    
        public String toString() {
            return new ToStringBuilder(this)
                .append("Id", getId())
                .toString();
        }
    
    }

  8. #18
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    mdeinum:
    thanks for the reply
    If you are defining ProxyFactoryBeans for instance, it is prefered to specify the target as an anonymous inner class. That way you prevent users from grabbing that bean and bypass the proxied instance.
    wondered about this, my question now would be (sorry for my ignorance)

    That way you prevent users from grabbing that bean and bypass the proxied instance.
    how they can do that?

    Esil2008:
    Code:
    // la couche [dao]
    private IDao dao;
    now you see the variable

    Code:
    <bean id="service" class="istia.st.springmvc.personnes.service.ServiceImpl" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
    	<property name="dao">
      	<ref local="myPersonneDao" /> 
      	</property>
      	</bean>
    see that myPersonneDao is an implementation of the interface, so here there is no problem

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  9. #19
    Join Date
    Jun 2007
    Location
    Marseille - France
    Posts
    78

    Default

    thank you very much, I know that it overindulge but I have another probelem
    now i have an exception
    Code:
    Etat HTTP 500 -
    
    type Rapport d'exception
    
    message
    
    description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.
    
    exception
    
    javax.servlet.ServletException: "Servlet.init()" pour la servlet personnes a généré une exception
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    	java.lang.Thread.run(Unknown Source)
    
    cause mère
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Personnes.ListController' defined in ServletContext resource [/WEB-INF/personnes-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [istia.st.springmvc.personnes.web.ListPersonnes] to required type [istia.st.springmvc.personnes.service.IService] for property 'service']
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1066)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:378)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:537)
    	org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:186)
    	org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initApplicationContext(SimpleUrlHandlerMapping.java:96)
    	org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
    	org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:84)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:277)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:395)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:283)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    	org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:306)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:251)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:220)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    	java.lang.Thread.run(Unknown Source)
    
    cause mère
    
    PropertyAccessExceptionsException (1 errors)
    	org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:781)
    	org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:753)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1057)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:378)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:537)
    	org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:186)
    	org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initApplicationContext(SimpleUrlHandlerMapping.java:96)
    	org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
    	org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:84)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:277)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:395)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:283)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    	org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:306)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:251)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:220)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    	java.lang.Thread.run(Unknown Source)
    
    note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/5.5.23.

  10. #20
    Join Date
    Jun 2007
    Location
    Marseille - France
    Posts
    78

    Default

    the file personnes-servlet.xml who manage the servlet is :
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    	<!-- les mappings de l'application-->
    	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    			<props>
    				<prop key="/list.html">Personnes.ListController</prop>
    				<prop key="/delete.html">Personnes.DeleteController</prop>
    				<prop key="/edit.html">Personnes.EditController</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<bean name="openSessionInViewInterceptor"  
        class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
           <property name="sessionFactory"><ref bean="sessionFactory"/></property>
      	</bean>
      
    	<!-- LES CONTROLEURS -->
    	<bean id="Personnes.ListController" 
    		class="istia.st.springmvc.personnes.web.ListPersonnes">
    		<property name="service">
    			<ref bean="Personnes.ListController"/>
    		</property>
    	</bean>
    	<bean id="Personnes.DeleteController" 
    		class="istia.st.springmvc.personnes.web.DeletePersonne">
    		<property name="service">
    			<ref bean="Personnes.DeleteController"/>
    		</property>
    	</bean>
    	<bean id="Personnes.EditController" 
    		class="istia.st.springmvc.personnes.web.EditPersonne">
    		<property name="sessionForm">
    			<value>true</value>
    		</property>
    		<property name="commandName">
    			<value>personne</value>
    		</property>
    		<property name="validator">
    			<ref bean="Personnes.Validator"/>
    		</property>
    		<property name="formView">
    			<value>edit</value>
    		</property>
    		<property name="service">
    			<ref bean="Personnes.EditController"/>
    		</property>
    	</bean>
    	<!-- le validateur -->
    	<bean id="Personnes.Validator" 
    		class="istia.st.springmvc.personnes.web.ValidatePersonne"/>
    	<!-- le résolveur de vues -->
    	<bean class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
    		<property name="basename">
    			<value>vues</value>
    		</property>
    	</bean>
    	<!-- le gestionnaire d'exceptions -->
    	<bean
    		class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    		<property name="exceptionAttribute">
    			<value>exception</value>
    		</property>
    		<property name="defaultStatusCode">
    			<value>200</value>
    		</property>
    		<property name="defaultErrorView">
    			<value>exception</value>
    		</property>
    	</bean>
    	<!-- le fichier des messages -->
    	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    		<property name="basename">
    			<value>messages</value>
    		</property>
    	</bean>
    </beans>
    and for example the code of EditPersonne is
    Code:
    package istia.st.springmvc.personnes.web;
    
    import java.text.SimpleDateFormat;
    import istia.st.springmvc.personnes.dao.DaoException;
    import istia.st.springmvc.personnes.entites.Personne;
    import istia.st.springmvc.personnes.hibernate.Personnes;
    import istia.st.springmvc.personnes.service.IService;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.beans.propertyeditors.CustomDateEditor;
    import org.springframework.validation.BindException;
    import org.springframework.web.bind.RequestUtils;
    import org.springframework.web.bind.ServletRequestDataBinder;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.mvc.SimpleFormController;
    
    public class EditPersonne extends SimpleFormController {
    	// service
    	IService service;
    
    	public IService getService() {
    		return service;
    	}
    
    	public void setService(IService service) {
    		this.service = service;
    	}
    
    	// enregistrement d'éditeurs de propriétés
    	protected void initBinder(HttpServletRequest request,
    			ServletRequestDataBinder binder) throws Exception {
    		// format attendu pour la date de naissance
    		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    		// format strict
    		dateFormat.setLenient(false);
    		// on enregistre un éditeur de propriétés String (dd/MM/yyyy) -> Date
    		// CustomDateEditor est fourni par Spring - il sera utilisé par Spring
    		// pour transformer
    		// la chaîne saisie dans le formulaire en type java.util.Date
    		// la date ne pourra être vide (2ième paramètre de CustomDateEditor)
    		binder.registerCustomEditor(java.util.Date.class, null,
    				new CustomDateEditor(dateFormat, false));
    	}
    
    	// préparation [Personne] à afficher
    	protected Object formBackingObject(HttpServletRequest request) {
    		// on récupère l'id de la personne
    		int id = RequestUtils.getIntParameter(request, "id", -1);
    		// ajout ou modification ?
    		Personnes personne = null;
    		if (id != -1) {
    			// modification - on récupère la personne à modifier
    			personne = service.getOne(id);
    		}else{
    			// ajout - on crée une personne vide
    			personne = new Personnes();
    			personne.setId(-1);
    		}
    		// on rend l'objet [Personne]
    		return personne;
    	}
    
    	// exécution de la commande
    	protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
    		// sauvegarde la personne ajoutée ou modifiée
    		Personnes personne = (Personnes) command;
    		int idPersonne = personne.getId();
    		try {
    			// sauvegarde de la personne
    			service.saveOne(personne);
    			// on redirige vers la liste des personnes
    			return new ModelAndView("r-list");
    		} catch (DaoException ex) {
    			// on note l'erreur
    			String message=idPersonne==-1 ? "personne.ajout.echec" : "personne.modification.echec";
    			errors.reject(message,new Object[]{ex.getMessage()},"Echec de la mise à jour: {0}");
    			// on réaffiche le formulaire
    			return showForm(request,response, errors);
    		}
    	}
    
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •