5

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.

ohp
  • 121
  • 2
  • 10

2 Answers2

5

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.

Gunnar
  • 18,095
  • 1
  • 53
  • 73
  • I figured that was the case... have already tried slf4j-api, but that doesn't appear to fix the issue.. Figured there must be a better way than randomly trying libraries. Have taken a step back from JSR-303 for the time being, as I don't think it will fix all of my validation issues anyway, but when I re-visit, will look at the processor plugin. – ohp May 28 '11 at 07:24
  • I'm not sure whether it helped the OP but surely it helped me solve that exception. Thanks man! – Lion Aug 04 '12 at 15:30
3

OP probably won't need it anymore, but maybe somebody else will.

I've had a similar problem with combination of Hibernate Validator 4.3 Final and slf4j 1.5.11 Finally I've found pair of versions that are willing to work together namely: -Hibernate Validator Final 4.2 -slf4j 1.6.6

danny
  • 41
  • 1
  • 5