OK, I'm trying to get a validator working with a jsp form.. Have just started using maven, so it's all a bit new... what's the best way of locating which repository I should be selecting for the above class? I already have the following entries for validation:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
I tried loading hibernate itself, but that broke the build: I'm using eclipse for persistence, and building fails after dragging in a huge number of prerequisite libraries.
I figured that I should get a better strategy than just stabbing away with repositories..
Just to be clear: I'm getting the error:
java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.engine.ConfigurationImpl
This should be in the hibernate-validator dependency, so not behaving as I would expect.
Hibernate Validator allows to express and validate application constraints. The default metadata source are annotations, with the ability to override and extend through the use of XML. It is not tied to a specific application tier or programming model and is available for both server and client application programming.
Hibernate Validator Annotation Processor It helps to detect glitches such as: Putting a constraint to bean properties which are not supported by that constraint (e.g. putting @Date to a String) Annotating the setter of a bean property instead of the getter. Adding constraints to static fields or methods.
The Javax bean validation API provides the following most frequently used annotations. The Hibernate validator provides the following commonly used annotations for validation. In case of product or project development we must use both the annotations for bean validation.
Validating constraints In the setUp() method, a Validator instance is retrieved from the ValidatorFactory . Validator instances are thread-safe and may be reused multiple times.
Do you have slf4j-api on the classpath (this should be pulled in by HV, but just to make sure)?
The NoClassDefFoundError doesn't mean that ConfigurationImpl is not available, but it couldn't be loaded (typically due to problems in the static initializer or by imports of the loaded class which are not available).
A side note on using the annotation processor: instead of adding it as project dependency you can also use it via the Maven annotation processor plugin. That way you can't accidentally import classes from it in your project. The set-up is described in detail in the Hibernate Validator reference guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With