OpenLiberty, JakartaEE8 and Hibernate Integration example


Openliberty provides JakartaEE8 support and all you have to do is enable 
<feature>jakartaee-8.0</feature>
It also enables jpa-2.2 + EclipseLink.

If you need to Hibernate with JakartaEE8 instead of EclipseLink, you have to manually include all the features of JakartaEE8 without jpa-2.2 and enable bells-1.0 . See the list below.

                    <feature>appClientSupport-1.0</feature>
        <feature>appSecurity-2.0</feature>
        <feature>appSecurity-3.0</feature>
        <feature>batch-1.0</feature>
        <feature>beanValidation-2.0</feature>
        <feature>cdi-2.0</feature>
        <feature>concurrent-1.0</feature>
        <feature>distributedMap-1.0</feature>
        <feature>ejb-3.2</feature>
        <feature>ejbHome-3.2</feature>
        <feature>ejbLite-3.2</feature>
        <feature>ejbPersistentTimer-3.2</feature>
        <feature>ejbRemote-3.2</feature>
        <feature>el-3.0</feature>
        <feature>j2eeManagement-1.1</feature>
        <feature>jacc-1.5</feature>
        <feature>jaspic-1.1</feature>
        <feature>javaMail-1.6</feature>
        <feature>jaxb-2.2</feature>
        <feature>jaxrs-2.1</feature>
        <feature>jaxrsClient-2.1</feature>
        <feature>jaxws-2.2</feature>
        <feature>jca-1.7</feature>
        <feature>jcaInboundSecurity-1.0</feature>
        <feature>jdbc-4.2</feature>
        <feature>jms-2.0</feature>
        <feature>jndi-1.0</feature>
        <feature>jpaContainer-2.2</feature>
        <feature>jsf-2.3</feature>
        <feature>json-1.0</feature>
        <feature>jsonb-1.0</feature>
        <feature>jsonp-1.1</feature>
        <feature>jsp-2.3</feature>
        <feature>managedBeans-1.0</feature>
        <feature>mdb-3.2</feature>
        <feature>restConnector-2.0</feature>
        <feature>servlet-4.0</feature>
        <feature>ssl-1.0</feature>
        <feature>wasJmsClient-2.0</feature>
        <feature>wasJmsSecurity-1.0</feature>
        <feature>wasJmsServer-1.0</feature>
        <feature>websocket-1.1</feature>
        <feature>bells-1.0</feature>

For hibernate integration, we are using jpaContainer-2.2 and bells-1.0.

First, add data sources and hibernate libraries to the server.


Next, add hibernate libraries to the application using commonLibraryRef



Then update persistence.xml.


Now you can use the persistence unit in your service layer.


project_structure
Project structure

Find the source code in my GitHub repository.

How to test? I have integrated the liberty maven plugin and you just need to run mvn libert:dev

MySQL schema is included in the repository.

If you encounter any issues, please report and I will address them.

openliberty_hibernate_jakartaee8_demo
Demo

References



Comments

  1. Is it possible to populate config folder with jars coming as dependencies in pom.xml ? I don't want to put all these jars manually.

    ReplyDelete
    Replies
    1. I don't think that is possible. You have to enable the features in openLiberty.
      May be you are looking for something like this >> https://www.tomitribe.com/blog/tomee-fat-jar-deployments/

      Delete

Post a Comment