Fork me on GitHub

Arturo Volpe

I am a software engineer. Interested in open source, open data and devops.

Using Hibernate 5.2 with Wilfly 10 in Docker

05 Jun 2016 » docker

The 1st of June Hibernate 5.2 was released, this release has some interesting features, like the consolidation of JPA in the core, and support for java 8 API’s.

Following the Hibernate official update guide, we need to replace the jars in the wildfly/modules folder.

In this blog, we will use the base docker image of Wildfly, with the tag 10.0.0.Final.

First, we create a simple Dockerfile:

FROM jboss/wildfly:10.0.0.Final
MAINTAINER Arturo Volpe <>

First, we need to get all the jars in the right place, the jars are available in Maven Central, so we add to our this

RUN cd $JBOSS_HOME/modules/system/layers/base/org/hibernate/main && \
    curl -O && \
    curl -O

RUN cd $JBOSS_HOME/modules/system/layers/base/org/hibernate/infinispan/main/ && \
    curl -O && \

This will download the 5.2 jars in the correct place (we need to replace hibernate-orm, envers, and infinispan).

The next step is remove the references and the jars of the previous release (for the base image, hibernate 5.0.7)

# Replace hibernate, hibernate-envers
RUN sed -i.bak "s/5.0.7/5.2.0/" module.xml && \
    sed -i.bak "/entitymanager/d" module.xml && \
    sed -i.bak "/java8/d" module.xml && \
    rm *.bak

# Replace infinispan
RUN rm *5.0.7.Final.jar && \
    sed -i.bak "s/5.0.7/5.2.0/" module.xml && \
    rm *.bak

And we are done, with this, hibernate by default must provide the 5.2.0.Final version of Hibernate.

To use this, we can do something like this:

EntityManager em;

public Session getSession() {
    return em.unwrap(Session.class);