Announcement Announcement Module
Collapse
No announcement yet.
[Exception] [Hibernate] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Exception] [Hibernate]

    Hi,
    I have the following exception :
    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 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for Droit in class com.pia.agp.mapping.Intervenant
    org.hibernate.PropertyNotFoundException: Could not find a getter for Droit in class com.pia.agp.mapping.Intervenant
    	at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
    	at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
    	at org.hibernate.mapping.Property.getGetter(Property.java:272)
    	at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)
    	at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)
    	at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
    	at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
    	at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
    	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
    	at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
    	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
    	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
    	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:825)
    	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:751)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
    	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:277)
    	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

  • #2
    because i add to my hbm file this code
    Code:
    <many-to-one name="Droit" class="com.pia.agp.mapping.Droit" column="DROIT_ID"/>
    to make relation between Intervenant and Droit. I have in Intervenant a foreigh key of Droit
    this my hbm files
    Intervenant.hbm.xml
    Code:
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
        
    <hibernate-mapping>
    <!-- 
        Created by the Middlegen Hibernate plugin 2.2
    
        http://boss.bekk.no/boss/middlegen/
        http://www.hibernate.org/
    -->
    
    <class 
        name="com.pia.agp.mapping.Intervenant" 
        table="intervenant"
        lazy="false"
    >
    
        <id
            name="intervenantId"
            type="java.lang.Integer"
            column="INTERVENANT_ID"
        >
        
            <generator class="increment" />
        </id>
    
        <property
            name="intervenantNom"
            type="java.lang.String"
            column="INTERVENANT_NOM"
            length="30"
        />
        <property
            name="intervenantPrenom"
            type="java.lang.String"
            column="INTERVENANT_PRENOM"
            length="30"
        />
        <property
            name="intervenantLogin"
            type="java.lang.String"
            column="INTERVENANT_LOGIN"
            length="30"
        />
        <property
            name="intervenantMdp"
            type="java.lang.String"
            column="INTERVENANT_MDP"
            length="30"
        />
        <property
            name="intervenantMdp2"
            type="java.lang.String"
            column="INTERVENANT_MDP2"
            length="30"
        />
        <property
            name="intervenantEmail"
            type="java.lang.String"
            column="INTERVENANT_EMAIL"
            length="30"
        />
        <property
            name="intervenantTel"
            type="java.lang.String"
            column="INTERVENANT_TEL"
            length="15"
        />
        <property
            name="intervenantFonction"
            type="java.lang.String"
            column="INTERVENANT_FONCTION"
            length="20"
        />
        <property
            name="intervenantDatedebutcontrat"
            type="java.sql.Date"
            column="INTERVENANT_DATEDEBUTCONTRAT"
            not-null="true"
            length="10"
        />
        <property
            name="intervenantDatefincontrat"
            type="java.sql.Date"
            column="INTERVENANT_DATEFINCONTRAT"
            not-null="true"
            length="10"
        />
    
        <property
            name="coutjournalierexperianId"
            type="java.lang.String"
            column="COUTJOURNALIEREXPERIAN_ID"
            not-null="true"
            length="32"
        />
    
        
    <!-- 
        <property
            name="droitId"
            type="java.lang.Long"
            column="DROIT_ID"
            not-null="true"
        />
    -->
    	<many-to-one name="Droit" class="com.pia.agp.mapping.Droit" column="DROIT_ID"/>
        <!-- Associations -->
      
    
    </class>
    </hibernate-mapping>
    et Droit.hbm.xml
    Code:
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
        
    <hibernate-mapping>
    <!-- 
        Created by the Middlegen Hibernate plugin 2.2
    
        http://boss.bekk.no/boss/middlegen/
        http://www.hibernate.org/
    -->
    
    <class 
        name="com.pia.agp.mapping.Droit" 
        table="droit"
        lazy="false"
    >
    
        <id
            name="droitId"
            type="java.lang.Long"
            column="DROIT_ID"
        >
        
            <generator class="increment" />
        </id>
    
        <property
            name="droitDroit"
            type="java.lang.String"
            column="DROIT_DROIT"
            length="30"
        />
    
        <!-- Associations -->
        <!-- 
      	<one-to-many
      		name="Intervenant" 
      		class="com.pia.agp.mapping.Intervenant" 
      		column="DROIT_ID"
      	/>
      	
    
    	<set inverse="true" name="Intervenant">
    			<key column="INTERVENANT_ID" />
    			<one-to-many class="com.pia.agp.mapping.Intervenant" />
    	</set>
    	-->	
    
    </class>
    </hibernate-mapping>

    With the relation many-to-one i want to make relation between the two tables, if I remove something for examle from the first table, it will be reflected on the second table .

    thanks for your help

    Comment


    • #3
      The Exception message is quite clear....

      Code:
      org.hibernate.PropertyNotFoundException: Could not find a getter for Droit in class com.pia.agp.mapping.Intervenant
      Create a get/setDroit in your Intervenant class. Only specifing the mapping in your xml isn't enough.

      Comment


      • #4
        hi ,
        i have a getter/setter method for droitId
        Code:
        public long getDroitId() {
                return this.droitId;
            }
        
            public void setDroitId(long droitId) {
                this.droitId = droitId;
            }

        Comment


        • #5
          oh, ok i made a mistake, i must have
          Code:
          <many-to-one name="droitId" class="com.pia.agp.mapping.Droit" column="DROIT_ID"/>
          thank you very much

          Comment


          • #6
            Ehr... that fails if I'm not mistaken...

            You are working with objects, let hibernate worry about the rest. Your Id should be a Droit instance not an id...

            Comment


            • #7
              Hi,
              now the application is deployed successfully, but when i try to execute my JSP , i have the following 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
              
              org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred while calling setter of com.pia.agp.mapping.Intervenant.droitId; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.pia.agp.mapping.Intervenant.droitId
              	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:406)
              	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:348)
              	javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
              	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
              
              cause mère
              
              org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred while calling setter of com.pia.agp.mapping.Intervenant.droitId; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.pia.agp.mapping.Intervenant.droitId
              	org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)
              	org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:413)
              	org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:371)
              	org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:844)
              	org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836)
              	com.pia.agp.dao.DaoIntervenantImpl.getAll(DaoIntervenantImpl.java:25)
              	com.pia.agp.service.ServiceIntervenantImpl.getAll(ServiceIntervenantImpl.java:30)
              	com.pia.agp.web.ListIntervenant.handleRequest(ListIntervenant.java:32)
              	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
              	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:723)
              	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)
              	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)
              	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:348)
              	javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
              	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
              
              cause mère
              
              org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.pia.agp.mapping.Intervenant.droitId
              	org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
              	org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
              	org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
              	org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3566)
              	org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
              	org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
              	org.hibernate.loader.Loader.doQuery(Loader.java:729)
              	org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
              	org.hibernate.loader.Loader.doList(Loader.java:2220)
              	org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
              	org.hibernate.loader.Loader.list(Loader.java:2099)
              	org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
              	org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
              	org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
              	org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
              	org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
              	org.springframework.orm.hibernate3.HibernateTemplate$31.doInHibernate(HibernateTemplate.java:853)
              	org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
              	org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:844)
              	org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836)
              	com.pia.agp.dao.DaoIntervenantImpl.getAll(DaoIntervenantImpl.java:25)
              	com.pia.agp.service.ServiceIntervenantImpl.getAll(ServiceIntervenantImpl.java:30)
              	com.pia.agp.web.ListIntervenant.handleRequest(ListIntervenant.java:32)
              	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
              	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:723)
              	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)
              	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)
              	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:348)
              	javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
              	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
              
              cause mère
              
              java.lang.IllegalArgumentException: argument type mismatch
              	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              	java.lang.reflect.Method.invoke(Unknown Source)
              	org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
              	org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
              	org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
              	org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3566)
              	org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
              	org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
              	org.hibernate.loader.Loader.doQuery(Loader.java:729)
              	org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
              	org.hibernate.loader.Loader.doList(Loader.java:2220)
              	org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
              	org.hibernate.loader.Loader.list(Loader.java:2099)
              	org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
              	org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
              	org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
              	org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
              	org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
              	org.springframework.orm.hibernate3.HibernateTemplate$31.doInHibernate(HibernateTemplate.java:853)
              	org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
              	org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:844)
              	org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836)
              	com.pia.agp.dao.DaoIntervenantImpl.getAll(DaoIntervenantImpl.java:25)
              	com.pia.agp.service.ServiceIntervenantImpl.getAll(ServiceIntervenantImpl.java:30)
              	com.pia.agp.web.ListIntervenant.handleRequest(ListIntervenant.java:32)
              	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
              	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:723)
              	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)
              	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)
              	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:348)
              	javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
              	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
              
              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.
              Apache Tomcat/5.5.23
              thanks

              Comment


              • #8
                Hi,
                can you explain more your proposition, with example of code if possible
                thanks

                Comment


                • #9
                  A Droit is an Droit not an Id...

                  Code:
                  public class Intervenant {
                    
                    private Droit droit;
                  
                    public Droit getDroit() {
                      return this.droit;
                    }
                  
                    public void setDroit(Droit droit) {
                      this.droit=droit;
                    }
                  
                  }
                  Mapping

                  Code:
                  <many-to-one name="droit" class="com.pia.agp.mapping.Droit" column="DROIT_ID"/>
                  Hibernate does the rest...

                  I suggest you take a look at the Hibernate manual chapter 3 I believe and take a look at the samples shipped with Spring and Hibernate.

                  Comment


                  • #10
                    Ok thank you very much

                    Comment

                    Working...
                    X