Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate types and JBoss compatibility issue

I'd like to use the hibernate-types library to map JSON collections to Postgres JSONB database columns using JPA and Hibernate but when I deploy my application I receive the following error:

Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/XProperty
at com.vladmihalcea.hibernate.type.json.internal.JsonTypeDescriptor.setParameterValues(JsonTypeDescriptor.java:58) 
at com.vladmihalcea.hibernate.type.json.JsonBinaryType.setParameterValues(JsonBinaryType.java:66) 
at org.hibernate.type.TypeFactory.injectParameters(TypeFactory.java:142)`

The class is indeed present in the jar provided by JBoss but it looks like the ModuleClassLoader is not able to find it. The Hibernate version provided by JBoss is 5.1.10.Final-redhat-1 and the version of the hibernate-commons-annotations where the XProperty class is defined is 5.0.1.Final-redhat-2. Any idea about what is missing to make things work? Thanks a lot

like image 544
patrick Avatar asked Sep 12 '18 08:09

patrick


2 Answers

Wildfly provide hibernate, and the class is searched in the ear. I changed ear's pom so:

path : "maven-ear-plugin".configuration.archive

<manifestEntries>
    <Dependencies>org.hibernate.commons-annotations</Dependencies>
</manifestEntries>

So find the XProperty class.

H.

like image 176
László Tóth Avatar answered Nov 16 '22 08:11

László Tóth


This can also be configured in WEB-INF/jboss-deployment-structure.xml file as:

<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.hibernate.commons-annotations"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>
like image 2
Tomasz Knyziak Avatar answered Nov 16 '22 08:11

Tomasz Knyziak