Weblogic has old version of Bean Validator

This is an issue of using the hibernate bean validator with weblogic 12. It may be more of a weblogic issue, but posting here in hopes that someone may have some ideas.

I have a dependency in my maven pom for hibernate-validator 6.0.13. I’m making use of HibernateValidatorConfiguration.constraintValidatorPayload (introduced in 6.0.8) to pass context to custom validators.

This works fine in my jUnit tests. However, when I actually run the application in weblogic 12.2.1, I see this exception:
java.lang.NoSuchMethodError: org.hibernate.validator.HibernateValidatorConfiguration.constraintValidatorPayload(Ljava/lang/Object;)Lorg/hibernate/validator/HibernateValidatorConfiguration;

I’ve found that weblogic has hibernate-validator built-in. Under wlserver/modules I see hibernate.validator.jar.

Doing a bit of debugging I’ve found this information for the hibernate validator package when running the application within weblogic:

  • Package name: org.hibernate.validator.internal.engine
  • Specification = Bean Validation
  • Spec Version = 1.1
  • Spec Vendor = null
  • Implementation = hibernate-validator
  • Impl Version = 5.1.3.Final
  • Impl Vendor = Oracle, Inc.

Whereas when running jUnit tests I have this version of hibernate validator

  • Package name: org.hibernate.validator.internal.engine
  • Specification = Bean Validation
  • Spec Version = 2.0
  • Spec Vendor = null
  • Implementation = hibernate-validator
  • Impl Version = 6.0.13.Final
  • Impl Vendor = org.hibernate.validator

Any thoughts on how to get access to the desired version of hibernate validator?

1 Like

Things like http://www.freshjavabeans.com/fjb/2015/05/14/override-jars-in-weblogic-libraries-and-use-those-in-your-ear-war/ could help.

Usually, for all the application servers, you have a way to prioritize the jars that are in your application. Note that you should probably also override the javax.validation classes.

HV 6.0.x and BV 2.0 are usually compatible with the old libraries but no idea if it will work in WebLogic.

BTW, you should upgrade to the latest 6.0.16.Final.

Using

  <container-descriptor>
       <prefer-application-packages>  
        <package-name>javax.validation.*</package-name>  
        <package-name>org.hibernate.validator.*</package-name>  
    </prefer-application-packages> 
    <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
  </container-descriptor>

in weblogic.xml solved the issue.

Thanks for the help!

1 Like

Thanks for your feedback.

Thank you so much DougBaughman :slight_smile: It really works