This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
In our web service project we are looking for a validation framework on java objects.
I tried iscreen which is pretty good but it does not have a maven repository. (Not sure if the code is production ready)
Tried spring validator which does not have much validations.
Tried using commons validator which did not look comfortable.
Tried JSR 303, they have only annotation based validation. Our beans are jaxb generated so we cannot put custom annotations. We can do it but its very hard.
We cannot use XSD schema validation before converting to jaxb objects because we accept both XML and JSON's as Input. (Wanted to convert JSON object to XML again for validation but its not a recommended architecture).
Well I still think JSR-303 is the way to go. The framework to use for that is Hibernate Validator
Now my first choice would be don't generate the Jaxb objects. In my opinion a lot of Object factories and unnecessary meta data is generated with it. Create your objects and annotate them how you want them then they can easily be used for XML and JSON as well as adding the JSR-303 annotations to them.
If you decide that you want to keep generating the objects you can either map them to JSR-303 annotated objects using a mapping library like Dozer or you can use xml to apply the JSR-303 rules to your generated objects and just use the generated objects themselves. See the documentation for that HERE.