JBoss will not start with Hibernate Validator

2019-09-19 04:02发布

问题:

I am trying to use Hibernate Validator. When attempting to start my JBoss I get the following:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name   'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl

My environment is:

  • JBoss 5.2
  • Java 1.8
  • Spring 3.2.11

These are what I have to work with.

I tried the following pom entries first.

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.1.0.Final</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>            
    <version>4.3.1.Final</version>
</dependency>

That did not work, gave the above error. So I read that I could just go to the latest Hibernate Validator, 5.1.3 and would not need the separate javax dependency, so I removed the javax dependency and set the pom to version 5.1.3 of hibernate validator. Same issue.

What am I missing? Everything I read shows exactly what I have. Is there another dependency I am missing? I have seen some mention of slfj, do I need to have that dependency? If so, what version?

Anyone have an example of a pom for the 4.3.1 or 5.1.3 that works?

Frustrating, seems like this should be very simple, so probably something really obvious I am missing.

回答1:

Got it working for now. Went with this config:

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.0.0.GA</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>            
    <version>4.0.2.GA</version>
</dependency>

I know this is not the latest, but the only one I could get working. Could not get 4.3.1 or 5.1.3 to work. But this gets me going for now.