-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: hibernate.PropertyNotFoundException: Could not find a getter
PostPosted: Mon Apr 18, 2011 2:39 pm 
Newbie

Joined: Mon Apr 18, 2011 2:12 pm
Posts: 5
Hi,

Hibernate throws Exception: org.hibernate.PropertyNotFoundException: Could not find a getter for idRep in class forms.PanneForm.
But i don't understand why
Hibernate version 3

ReparateurForm.hbm

Code:
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="forms">
   <class name="forms.ReparateurForm" table="reparateur">
      <id
         column="idRep"
         name="idRep"
         type="string"
      >
         <generator class="assigned" />
      </id>
      <property
         column="numTelRep"
         length="40"
         name="numTelRep"
         not-null="false"
         type="string"
       />
      <property
         column="desRep"
         name="desRep"
         not-null="false"
         type="string"
       />
      <set inverse="true" name="pannes">
         <key column="idRep" />
         <one-to-many class="forms.PanneForm" />
      </set>
      
   </class>
</hibernate-mapping>




PanneForm.hbm


Code:
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="forms">
   <class name="forms.PanneForm" table="panne">
      <id
         column="idPan"
         name="idPan"
         type="string">
         <generator class="assigned" />
      </id>
      <property
         column="descPan"
         length="100"
         name="descPan"
         not-null="false"
         type="string"
       />
      <property
         column="datePan"
         length="20"
         name="datePan"
         not-null="false"
         type="string"
       />
      
      
      <many-to-one
         class="forms.ReparateurForm"
         name="idRep"
         not-null="false">
         <column name="idRep" />
      </many-to-one>
      
   </class>
</hibernate-mapping>




ReparateurForm.java


Code:
package forms;

import java.util.HashSet;
import java.util.Set;

import org.apache.struts.validator.ValidatorForm;


public class ReparateurForm extends ValidatorForm {
   
   
   private String idRep;
   private String numTelRep;
   private String desRep;
   
   
   

   public String getIdRep() {
      return idRep;
   }

   public void setIdRep(String idRep) {
      this.idRep = idRep;
   }

   public String getNumTelRep() {
      return numTelRep;
   }

   public void setNumTelRep(String numTelRep) {
      this.numTelRep = numTelRep;
   }

   public String getDesRep() {
      return desRep;
   }

   public void setDesRep(String desRep) {
      this.desRep = desRep;
   }

   private Set pannes = new HashSet();

   public Set getPannes() {
      return pannes;
   }

   public void setPannes(Set pannes) {
      this.pannes = pannes;
   }

}




PanneForm.java

Code:
package forms;

import org.apache.struts.validator.ValidatorForm;




public class PanneForm extends ValidatorForm {


   private String idPan;
   private String descPan;
   private String datePan;
   
   private MaterielForm materiels;
   private ReparateurForm reparateurs;
   


   public String getIdPan() {
      return idPan;
   }
   public void setIdPan(String idPan) {
      this.idPan = idPan;
   }
   public String getDescPan() {
      return descPan;
   }
   public void setDescPan(String descPan) {
      this.descPan = descPan;
   }
   public String getDatePan() {
      return datePan;
   }
   public void setDatePan(String datePan) {
      this.datePan = datePan;
   }
   public MaterielForm getMateriels() {
      return materiels;
   }
   public void setMateriels(MaterielForm materiels) {
      this.materiels = materiels;
   }
   public ReparateurForm getReparateurs() {
      return reparateurs;
   }
   public void setReparateurs(ReparateurForm reparateurs) {
      this.reparateurs = reparateurs;
   }
   
   
   
}



thanks for your help


Top
 Profile  
 
 Post subject: Re: hibernate.PropertyNotFoundException: Could not find a getter
PostPosted: Mon Apr 18, 2011 3:39 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
This mapping:

Code:
<many-to-one
         class="forms.ReparateurForm"
         name="idRep"
         not-null="false">
         <column name="idRep" />
      </many-to-one>


doesn't match with the getter/setter:

Code:
   public ReparateurForm getReparateurs() {
      return reparateurs;
   }
   public void setReparateurs(ReparateurForm reparateurs) {
      this.reparateurs = reparateurs;
   }


You'll either need to change your method names or the name property of the <many-to-one>.


Top
 Profile  
 
 Post subject: Re: hibernate.PropertyNotFoundException: Could not find a getter
PostPosted: Mon Apr 18, 2011 4:43 pm 
Newbie

Joined: Mon Apr 18, 2011 2:12 pm
Posts: 5
like this????

<many-to-one
class="forms.ReparateurForm"
name="getReparateurs"
not-null="false">
<column name="idRep" />
</many-to-one>


Top
 Profile  
 
 Post subject: Re: hibernate.PropertyNotFoundException: Could not find a getter
PostPosted: Mon Apr 18, 2011 6:40 pm 
Newbie

Joined: Mon Apr 18, 2011 2:12 pm
Posts: 5
FINALLY IT'S WORK THANK YOU SOOOOOOOOOOOOOOOO MATCH :D


Top
 Profile  
 
 Post subject: Re: hibernate.PropertyNotFoundException: Could not find a getter
PostPosted: Sat Apr 23, 2011 5:34 pm 
Newbie

Joined: Mon Apr 18, 2011 2:12 pm
Posts: 5
i need to create a new Panne so this is the jsp:

creerPan.jsp:

Code:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ page contentType="text/html; charset=iso-8859-1" language="java"
   import="java.util.*,managers.*,forms.*"
   errorPage=""%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%

   ReparateurManager Rmanager = new ReparateurManager();
   List Rlist1 = (List) Rmanager.getListReparateur();
   request.setAttribute("Rlist", Rlist1);
   
   

   %>
   
<html>
<head>
<title>Creer Nouveau Panne</title>
</head>
<body>
<html:form action="ajoutPan" >
   <center>
     <h1><u>Création d'un nouveau Panne</u></h1>
   </center>

   <div>
   
   <table border="1" bordercolor="#FFF1BF" bgcolor="#FFFDE6" >
   <tr>
   <td width="169" height="21" bgcolor="#FFF5D7"><div align="left" class="style8">Matricule :</div></td>
   <td width="227" bgcolor="#FFF5D7"><html:text property="idPan" /></td>
   </tr>
   <tr>
   <td bgcolor="#FFF5D7"><div align="left" class="style8">Déscription :</div></td>
   <td bgcolor="#FFF5D7"><html:text property="descPan" /></td>
   </tr>
   <tr>
   <td bgcolor="#FFF5D7"><div align="left" class="style8">Date de panne :</div></td>
   <td bgcolor="#FFF5D7"><html:text property="datePan" /></td>
   </tr>
   
    <tr>
   <td bgcolor="#FFF5D7"><div align="left" class="style8">Réparateur :</div></td>
    <html:select property="reparateurs">
    <html:optionsCollection property="Rlist" value="desRep" label="Réparateurs"/>
    </html:select>
    </tr>
   </table>
   <br>
   <CENTER><html:submit property="operation">
      <bean:message key="operation.creerPan" />
</html:submit>
<html:reset>reset</html:reset> </CENTER>
   
  </div>
</html:form>
</body>
</html>



this is the panne manager:

PanneManager.java

Code:
package managers;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import forms.PanneForm;

import util.HibernateUtil;

public class PanneManager {
   
   private boolean rep=false;   
    private boolean rep1 = false;



public boolean trouve(){
   
   return rep;
}

public boolean trouve1() {
   return rep1;
}



public List getListPanne() {

   Session session = HibernateUtil.getSessionFactory().openSession();

   session.beginTransaction();
   
   List result = session.createQuery("from PanneForm as P order by P.idPan").list();

   session.getTransaction().commit();

   session.close();

   return result;
}


public void creerPan(PanneForm Pan) {
   Transaction tx = null;
   Session session = HibernateUtil.getSessionFactory().openSession();
   try {
      tx = session.beginTransaction();
      session.save(Pan);
      tx.commit();
   } catch (HibernateException e) {
      e.printStackTrace();
      if (tx != null && tx.isActive())
         tx.rollback();
   } finally {
      session.flush();
      session.close();
   }

}

}



this is the Reparateur manager:


ReparateurManager.java

Code:
package managers;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import forms.ReparateurForm;

import util.HibernateUtil;

public class ReparateurManager {   private boolean rep=false;   
private boolean rep1 = false;



public boolean trouve(){
   
   return rep;
}

public boolean trouve1() {
   return rep1;
}

public List getListReparateur() {

   Session session = HibernateUtil.getSessionFactory().openSession();

   session.beginTransaction();
   
   List result = session.createQuery("from ReparateurForm as R order by R.idRep").list();

   session.getTransaction().commit();

   session.close();

   return result;
}


public void creerRep(ReparateurForm Rep) {
   Transaction tx = null;
   Session session = HibernateUtil.getSessionFactory().openSession();
   try {
      tx = session.beginTransaction();
      session.save(Rep);
      tx.commit();
   } catch (HibernateException e) {
      e.printStackTrace();
      if (tx != null && tx.isActive())
         tx.rollback();
   } finally {
      session.flush();
      session.close();
   }

}

}



struts-config.xml

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>

<form-beans type="org.apache.struts.action.ActionFormBean">

<form-bean name="fournisseurForm" type="forms.FournisseurForm" /> 
<form-bean name="panneForm" type="forms.PanneForm" /> 
<form-bean name="materielForm" type="forms.MaterielForm" /> 
<form-bean name="reparateurForm" type="forms.ReparateurForm" /> 


</form-beans>

<action-mappings type="org.apache.struts.action.ActionMapping">


      <action path="/ajoutPan" type="actions.PanneAction"
          scope="request" name="panneForm" parameter="operation"
         input="/vues/creerPan.jsp" validate="false">
         <forward name="succes" path="/vues/listePan.jsp"
            redirect="true" />
      </action>
   
</action-mappings>
      
      <message-resources parameter="ApplicationResource" />
      
</struts-config>





but when i run the application i have this error:


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.apache.jasper.JasperException: Exception in JSP: /vues/creerPan.jsp:85

82: <tr>
83: <td bgcolor="#FFF5D7"><div align="left" class="style8">Matériels :</div></td>
84: <html:select property="materiels">
85: <html:optionsCollection property="Mlist" value="refMat" label="Materiels"/>
86: </html:select>
87: </tr>
88: <tr>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


cause mère

javax.servlet.ServletException: No getter method for property Mlist of bean org.apache.struts.taglib.html.BEAN
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.vues.creerPan_jsp._jspService(creerPan_jsp.java:150)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


cause mère

javax.servlet.jsp.JspException: No getter method for property Mlist of bean org.apache.struts.taglib.html.BEAN
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968)
org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsCollectionTag.java:219)
org.apache.jsp.vues.creerPan_jsp._jspx_meth_html_005foptionsCollection_005f0(creerPan_jsp.java:341)
org.apache.jsp.vues.creerPan_jsp._jspx_meth_html_005fselect_005f0(creerPan_jsp.java:310)
org.apache.jsp.vues.creerPan_jsp._jspx_meth_html_005fform_005f0(creerPan_jsp.java:201)
org.apache.jsp.vues.creerPan_jsp._jspService(creerPan_jsp.java:140)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/5.5.29.


--------------------------------------------------------------------------------


Top
 Profile  
 
 Post subject: Re: hibernate.PropertyNotFoundException: Could not find a getter
PostPosted: Sun Apr 24, 2011 4:35 pm 
Newbie

Joined: Mon Apr 18, 2011 2:12 pm
Posts: 5
^
^
^
^
^
Please helpppppppppp


Top
 Profile  
 
 Post subject: Re: hibernate.PropertyNotFoundException: Could not find a getter
PostPosted: Mon Apr 25, 2011 9:26 am 
Newbie

Joined: Sun Apr 24, 2011 12:28 pm
Posts: 6
koukou0687 wrote:
^
^
^
^
^
Please helpppppppppp

Read the error message: javax.servlet.jsp.JspException: No getter method for property Mlist of bean org.apache.struts.taglib.html.BEAN
Where is your getter method for Mlist?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.