Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
JSR 303 Bean validation - localized messages on GlassFish 4.1 - NoClassDefF
1) I have problem with localized bean validations in Vaadin.
What is working:
- Bean validations with localized messages (in ValidationMessages.properties) in a simple servlet application without Vaadin (see bean-validation-war.tar.gz).
- Bean validations without localized messages (messages are hardcoded in annotations) in a Vaadin application
What is not working:
- Bean validations with localized messages in a Vaadin application
In such case, I get error (see stacktrace-1.txt):
java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateExpression(ResourceBundleMessageInterpolator.java:227) at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateMessage(ResourceBundleMessageInterpolator.java:187) at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolate(ResourceBundleMessageInterpolator.java:11
(on the same Vaadin form I have also fields without localized messages ant its validations work well)
I deploy both applications on the same instance of GlassFish 4.1. This application server has embedded a hibernate-validator but I also tried to add this library (in various versions) in my pom.xml (as described in Vaadin documentation) with same result. I also tried adding validation-api and javax.el-api libraries with no luck. Maybe there is a combination of versions that is working? Any help is appreciated.
2) The second (currently minor) issue: I afraid that in a vaadin application the validation.xml is ignored. Despite the fact that in the log I see:
... [org.hibernate.validator.internal.xml.ValidationXmlParser] ... [[HV000007: META-INF/validation.xml found. Parsing XML based configuration.]]
the content of this file is ignored -- I tried to set a default-provider or message-interpolator to non-existing classes which should lead to an error and I even tried to provide invalid XML file, but no error occured -- this file is simply ignored. But when I do the same in my non-vaadin web application, I got error as expected:
javax.validation.ValidationException: HV000099: Unable to instantiate validation provider
So the file is loaded and not ignored.
Some version info:
Operating system: GNU/Linux (Kubuntu 14.10)
Java: OpenJDK 8
Vaadin CDI: 1.0.3
application format: EAR (WAR + EJB + common LIB)
Solved: I have upgraded to Vaadin 7.5.2 and localized bean validations are now working!
Part 1) is solved. But part 2) not: my vaadin application still ignores the validation.xml file. Although in the log there is:
HV000007: META-INF/validation.xml found. Parsing XML based configuration.
I have searched Vaadin source code and didn't find any ignoreXmlConfiguration. How can I enable it?