java.lang.ClassNotFoundException: org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper

后端 未结 2 332
遇见更好的自我
遇见更好的自我 2021-01-13 08:46

During the validation of entity (before insertion) on my Spring MVC app I get the following error :

    ...
    at io.undertow.server.Connectors.executeRoot         


        
2条回答
  •  被撕碎了的回忆
    2021-01-13 09:23

    The error mentioned is occurring due to a possible clash of dependency versions.

    WildFly already provides both hibernate-core and hibernate-validator dependencies in \modules\system\layers\base\org\hibernate.

    In the case of WildFly10, the dependencies' versions are the following:

    • hibernate-core-5.0.7.Final
    • hibernate-validator-5.2.3.Final

    Therefore, on your pom.xml, you could place your Hibernate dependencies as provided and let the container use its own:

    
        org.hibernate
        hibernate-core
        5.1.0.Final
        provided
    
    
    
        org.hibernate
        hibernate-validator
        5.2.4.Final
        provided
    
    

    But if you want to provide your own dependencies, as mentioned on WildFly 10 documentation, you should provide a jboss-deployment-structure.xml, where you basically tell WildFly to disregard it's own dependencies:

    
        
            
                
            
        
    
    

    This way, the container will load the dependencies that were packaged with your application and that are present on your WAR's WEB-INF/lib folder.

    EDIT

    After going to the source code of PersistenceUtilHelper.isLoadedWithoutReference, one notices that, in Hibernate 5.1, it no longer references the class FieldInterceptionHelper, on line 119, where the error occurs. Whereas in the version 5.0 it still does.

    I also suggest you to add the most recent version of the hibernate-entitymanager dependency, in order to be in accordance with the other Hibernate dependencies:

    
        org.hibernate
        hibernate-entitymanager
        5.1.0.Final
    
    

提交回复
热议问题