Search code examples
javajakarta-eewebsphere-libertyjpa-2.1hibernate-entitymanager

How to deploy JavaEE 7 / JPA 2.1 Dynamic Web Application to IBM Liberty Profile WITHOUT web.xml


I have a Dynamic Web Application that access a DB2 v10 zOS Database.

I wish to use Hibernate 5 as my JPA 2.1 Provider and access my EntityManager via CDI.

I do not want to use the Spring Framework at all; I also do not wish to have a web.xml file.

How can I configure my persistence context and persistence unit WITHOUT using web.xml when deploying my application to WebSphere Application Server Liberty v9 Beta?


Solution

  • The first result on google for "websphere liberty hibernate" gave me the link to a sample app that uses Liberty with Hibernate.

    WASdev Liberty + Hibernate sample

    Note that the jpaApp.war DOES use a web.xml, but this can easily be avoided by using the proper @WebServlet annotation and changing the persistence.xml to point to a server-defined datasource instead of a component-defined datasource.

    @WebServlet(displayName="JPA Servlet", urlPatterns="/JPAServlet")
    public class JPAServlet extends HttpServlet {
        // ...
    }