0

I'm trying to validate something using the GWT BeanValidation but these two lines are giving me some trouble:

Validator validator=Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Contact>> violations = validator.validate(contact, Default.class);

The thing is, I have imported the corresponding classes:

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.groups.Default;

But still, the Validator, Validation, ConstraingViolation and Default references in the code are underlined in red and the error they show is:

javax.validation.Validator can not be found in source packages. Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly.

I have checked that the necessary lib validation-api-1.0.0.GA.jar is in the classpath and everything seems normal.

Anyone happens to know what could be the problem?

thanks!!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Neets
  • 4,094
  • 10
  • 34
  • 46

2 Answers2

1

I see only two possibilities

  1. Check the size of jar file , either in your local maven repository which your build path is pointing to or check that in your eclipse by browsing its source code to double check its there :)
  2. Have you inherited this is any awt module using ? Can you check its syntax or if it is really required?
Manish Singh
  • 3,463
  • 22
  • 21
  • yeah, the problem is that GWT doesn't let you use any class freely. First it has to be inherited via a module in the gwt.xml. In the end, I chose to work with another validation library: GWT-VL – Neets Mar 28 '11 at 15:40
0

Do you have validator-implementation in your classpath? AFAIK, javax.validation is only the API (interfaces), you'll need an actual validator-implementation to use it. See for example Hibernate Validator.

esaj
  • 15,875
  • 5
  • 38
  • 52