Hibernate - Error activating Bean Validation integration

前端 未结 2 1341
我寻月下人不归
我寻月下人不归 2020-12-07 01:45

I am trying to set up Hibernate. But when i try to create my Session Factory, with this code:

Configuration configuration = new Configuration();
configuratio         


        
2条回答
  •  没有蜡笔的小新
    2020-12-07 02:22

    The problem arises from having similar packaged structure jar. In my case, I had javaee6 as provided, and javax.validation1.1.0.Final both have the package javax.validation.spi.

    Since I used Maven, I placed javax.validation1.1.0 dependency on top of javaee6. So I can use 1.1.0 methods. Otherwise, if the javaee6 is on top I cannot access/ override validation1.1.0 methods.

    It compiled fine, but while running in Tomee 1.7.5 WebProfile I faced NoSuchMethodError. So, added the javax.validation1.1.0 Final jar to lib folder of Tomee, but still somehow javaee6 jar's validation got triggered first.

    So I renamed the file javax.validation1.1.0.Final to ijavax.validation1.1.0.Final, so that when alphabetically ordered it gets loaded before javaee6, then it worked!!

    Check here for class loader ordering of jars in tomcat Order of loading jar files from lib directory

提交回复
热议问题