GWT ERROR: No source code is available for type org.hibernate.validator.constraints.impl.SizeValidatorForString
-
26-10-2019 - |
题
I am trying to set up client-side validation for my GWT app by following instructions provided by the following link:
http://code.google.com/p/google-web-toolkit/wiki/BeanValidation
...and by looking at the validation sample provided in:
http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/validation
I have set up the exact same project as in the validation sample, but as a regular GWT project - not using Maven. I have hibernate-validator-4.2.0.Final.jar and slf4j-api-1.6.1.jar on both my client and server classpaths. However; I am still getting the following error at runtime:
No source code is available for type org.hibernate.validator.constraints.impl.SizeValidatorForString; did you forget to inherit a required module?
No source code is available for type org.hibernate.validator.constraints.impl.SizeValidatorForCollection; did you forget to inherit a required module?
No source code is available for type org.hibernate.validator.constraints.impl.SizeValidatorForMap; did you forget to inherit a required module?
The classes mentioned are in hibernate-validator-4.2.0.Final.jar. Therefore, I am a bit confused. Could it be that the super-source statement in Validation.gwt.xml that is hiding the classes defined in the jar?
解决方案
Note the error: it isn't that the classes, but that the source is missing. Make sure you have a jar with the classes on the client classpath as well.
The super-source statement is used to define a package that contains source that should be used to provide client-equivalent functionality for some non-client package.
其他提示
you need to have in your classpath both:hibernate-validator-4.2.0.Final-sources.jar and hibernate-validator-4.2.0.Final.jar
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
<classifier>sources</classifier>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>