During the validation of entity (before insertion) on my Spring MVC app I get the following error :
...
at io.undertow.server.Connectors.executeRoot
The error mentioned is occurring due to a possible clash of dependency versions.
WildFly already provides both hibernate-core and hibernate-validator dependencies in <wildfly_dir>\modules\system\layers\base\org\hibernate.
In the case of WildFly10, the dependencies' versions are the following:
Therefore, on your pom.xml, you could place your Hibernate dependencies as provided and let the container use its own:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
<scope>provided</scope>
</dependency>
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:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate" slot="main" />
</exclusions>
</deployment>
</jboss-deployment-structure>
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:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
The following worked for me:
hibernate-core-5.1.0.Final
hibernate-entitymanager-5.1.0.Final
hibernate-validator-5.2.4.Final