1

In my Spring 3.0.5 Web MVC application I have defined a model class with a property annotated with @SafeHtml. When Spring tries to validate this model object, it blows up with the following:

HTTP ERROR: 500

org.jsoup.Jsoup.isValid(Ljava/lang/String;Lorg/jsoup/safety/Whitelist;)Z
RequestURI=/guestbook/process-new-entry

Caused by:

java.lang.NoSuchMethodError: org.jsoup.Jsoup.isValid(Ljava/lang/String;Lorg/jsoup/safety/Whitelist;)Z
    at org.hibernate.validator.constraints.impl.SafeHtmlValidator.isValid(SafeHtmlValidator.java:62)
    at org.hibernate.validator.constraints.impl.SafeHtmlValidator.isValid(SafeHtmlValidator.java:34)
    at org.hibernate.validator.engine.ConstraintTree.validateSingleConstraint(ConstraintTree.java:278)
    ... (abbreviated)

I understand this is caused by my not using the right version of Jsoup. (I'm using 0.2.2) In this version I am using, the method signature for isValid() has changed or has been removed altogether. So to resolve this, I believe I should use a different version of Jsoup. Am I right?

Hypothetically, what if I wanted to keep using the version I am currently using - what is the other part that needs a change in version? Is it the Hibernate validator?

Also, can anyone suggest a way to find out which version of Jsoup to use? How do you usually resolve this kind of errors?

And, one final question, what does to "Z" letter at the end of the line mean? I sometimes come across other letters as well. What do these letters mean? Is this documented anywhere?

Thank you all in advance for helping me arrive at a better understanding of how these version discrepancies should be resolved, so I wouldn't need to waste so much of my time in the future... Cheers!

Peter Perháč
  • 20,434
  • 21
  • 120
  • 152
  • that's a good question. Yes, I am. So why am I getting this problem? If I don't define a dependency on JSuop, my app blows up with ClassNotFoundDef or something like that. I'd have to try again just to see. It's strange I have to define the dependency manually. – Peter Perháč Jul 31 '11 at 09:05

1 Answers1

2
  1. Yes
  2. If you want to keep using Jsoup 0.2.2, you'd have to see if there's a version of hibernate-validator that will work with that version, which seems unlikely since I think the @SafeHtml constraint is pretty new, or you'd have to see if you can modify the source code to work with that version.
  3. If you want a definitive answer to which Jsoup version hibernate expects, you can check the pom of whichever version of the validator artifact you're using. They're easily available at maven central.
  4. "Z" is the type descriptor for the primitive boolean type. The VM spec has a table that lists the possible values.
Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199
  • oh, this is probably the most complete answer I ever got on SO. You've answered all my questions. The maven central link is excellent. I was looking into .pom files in ibiblio, but these contained only licence information (e.g.: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/hibernate/hibernate-validator/3.0.0.ga/hibernate-validator-3.0.0.ga.pom). – Peter Perháč Jul 31 '11 at 09:02
  • And thanks for the link in (4.). Finally the mistery is solved, and how simple it is... I just never came across this information. Thank you very much, again. Cheers – Peter Perháč Jul 31 '11 at 09:03