From noreply at atlassian.com Sat Aug 1 12:48:12 2009 Content-Type: multipart/mixed; boundary="===============5824471205578610140==" MIME-Version: 1.0 From: Emmanuel Bernard (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Commented: (HV-196) validateValue incorrectly reports java.lang.IllegalArgumentException: Invalid property path. There is no property listOfString in entity simple_bv_servlet.Person Date: Sat, 01 Aug 2009 11:48:12 -0500 Message-ID: <509923463.14751249145292203.JavaMail.j2ee-opensource-projects@vps07.contegix.com> In-Reply-To: 278757689.14681249076651986.JavaMail.j2ee-opensource-projects@vps07.contegix.com --===============5824471205578610140== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://opensource.atlassian.com/projects/hibernate/browse/HV-196?page= =3Dcom.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focused= CommentId=3D33692#action_33692 ] = Emmanuel Bernard commented on HV-196: ------------------------------------- Reproduced. Need to investigate on two fronts: - fix to comply with the contract - should the contract be altered to ignored nonexisting properties? > validateValue incorrectly reports java.lang.IllegalArgumentException: Inv= alid property path. There is no property listOfString in entity simple_bv_s= ervlet.Person > -------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------- > > Key: HV-196 > URL: http://opensource.atlassian.com/projects/hibernate/b= rowse/HV-196 > Project: Hibernate Validator > Issue Type: Bug > Affects Versions: 4.0.0.Beta2 > Environment: HEAD of JSR-303 RI > Reporter: Ed Burns > Attachments: simple-bv-servlet.war > > > Calling validator.validateValue() seems to fail when it shouldn't. > Consider this pojo: > 8<---------------------------------- > package simple_bv_servlet; > import java.util.List; > import javax.validation.constraints.NotNull; > public class Person { > @NotNull > private String firstName; > public String getFirstName() { > return firstName; > } > public void setFirstName(String firstName) { > this.firstName =3D firstName; > } > @NotNull > private String lastName; > public String getLastName() { > return lastName; > } > public void setLastName(String lastName) { > this.lastName =3D lastName; > } > private List listOfString; > public List getListOfString() { > return listOfString; > } > public void setListOfString(List listOfString) { > this.listOfString =3D listOfString; > } > = > } > 8<---------------------------- > And consider this selvlet which validates this pojo in its doGet() impl. > 8<-------------------------------------- > package simple_bv_servlet; > import java.io.IOException; > import java.io.PrintWriter; > import java.util.ArrayList; > import java.util.List; > import java.util.Set; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > import javax.validation.ConstraintViolation; > import javax.validation.Validation; > import javax.validation.ValidatorContext; > import javax.validation.ValidatorFactory; > public class SimpleBVServlet extends HttpServlet { > @Override > protected void doGet(HttpServletRequest req, HttpServletResponse resp= ) throws ServletException, IOException { > PrintWriter out =3D resp.getWriter(); > resp.setContentType("text/html"); > out.print("SimpleBVServlet"); > = > ValidatorFactory validatorFactory =3D null; > = > validatorFactory =3D Validation.buildDefaultValidatorFactory(); > = > out.print("

"); > out.print("Obtained ValidatorFactory: " + validatorFactory + "."); > out.print("

"); > = > ValidatorContext validatorContext =3D validatorFactory.usingConte= xt(); > javax.validation.Validator beanValidator =3D validatorContext.get= Validator(); > out.print("

"); > out.print("Validating invalid person class using validateValue."); > out.print("

"); > = > List value =3D new ArrayList(); > value.add("one"); > value.add("two"); > value.add("three"); > Set> violations =3D > beanValidator.validateValue(Person.class, "listOfString",= value); > = > if (violations.isEmpty()) { > out.print("

"); > out.print("No ConstraintViolations found."); > out.print("

"); > } else { > for (ConstraintViolation curViolation : violations) { > out.print("

"); > out.print("ConstraintViolation: message: " + curViolation= .getMessage() + > " propertyPath: " + curViolation.getPropertyPath(= )); > out.print("

"); > } > } > Person person =3D new Person(); > = > out.print("

"); > out.print("Validating invalid person instance using validate."); > out.print("

"); > = > violations =3D beanValidator.validate(person); > = > if (violations.isEmpty()) { > out.print("

"); > out.print("No ConstraintViolations found."); > out.print("

"); > } else { > for (ConstraintViolation curViolation : violations) { > out.print("

"); > out.print("ConstraintViolation: message: " + curViolation= .getMessage() + > " propertyPath: " + curViolation.getPropertyPath(= )); > out.print("

"); > } > } > = > out.print("

"); > out.print("Validating valid person."); > out.print("

"); > = > person.setFirstName("John"); > person.setLastName("Yaya"); > = > violations =3D beanValidator.validate(person); > = > if (violations.isEmpty()) { > out.print("

"); > out.print("No ConstraintViolations found."); > out.print("

"); > } else { > for (ConstraintViolation curViolation : violations) { > out.print("

"); > out.print("ConstraintViolation: message: " + curViolation= .getMessage() + > " propertyPath: " + curViolation.getPropertyPath(= )); > out.print("

"); > } > } > = > out.print(""); > = > } > = > = > } > 8<------------------------ > The call to = > Set> violations =3D > beanValidator.validateValue(Person.class, "listOfString",= value); > = > causes this exception to be thrown: > java.lang.IllegalArgumentException: Invalid property path. There is no pr= operty listOfString in entity simple_bv_servlet.Person > But I say, doch, there is such a property on the Person. = > This is new behavior in 4.0.0.Beta2, and it's breaking Glassfish. > Thanks, > Ed -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============5824471205578610140==--