OpenJPA Logo   ASF Logo

JEST facilities are available as a HTTP servlet, org.apache.openjpa.persistence.jest.JESTServlet.

JESTServlet can be deployed in a servlet container e.g. Tomcat in two possible modes: primary or auxiliary.

Deployment Modes

In primary mode, the JESTServlet itself instantiates a persistence unit during initialization.

In auxiliary mode, the JESTServlet discovers a persistence unit used by another component X. The sibling component X must satisfy the following for JEST to discover its persistent unit

  • The component X and JESTServlet must belong to the same deployment unit.
  • The component X must activate OpenJPA's native EntityManagerFactory pool. The pool is activated by switching on openjpa.EntityManagerFactoryPool configuration property to true. This property is available only via runtime configuration. The following code example ensures that OpenJPA's native EntityManagerFactory pool is active.
Activation of OpenJPA's native EntityManagerFactory pool
Map<String,Object> props = new HashMap<String, Object>();
props.put("openjpa.EntityManagerFactoryPool", "true");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("myPU",props);

JESTServlet accepts following initial configuration parameters

persistence.unitName of the persistent unit. Must be specified.
standalonetrue implies primary mode. Defaults to false.
debugtrue implies verbose tracing of HTTP requests. Defaults to false.

The following deployment descriptor WEB-INF/web.xml deploys JESTServlet in auxiliary mode

JEST Deployment Descriptor in Auxiliary Mode
<web-app version="2.4" 
    <display-name>Demo Application with JEST Servlet</display-name>  
        An example of deploying a simple web application with JEST servlet.
        This descriptor specifies the Demo Application servlet as well as JEST servlet.

            This is the Demo Application Servlet.
            The servlet is mapped to URL pattern /app/* so this servlet can be accessed as
            where "demo" is the name of the deployed web application.
            Assume that the Demo Application Servlet is using a persistence unit named 
            'jestdemo'. The JEST Servlet will require the persistence unit name to
            browse the Demo Application.		      


    <!-- Deployment descriptor for JESTServlet.	    -->
            This is the JEST servlet. 
            JEST Servlet needs to know the name of the persistence unit used by the 
            Demo Application. The unit name is specified by mandatory "persistence.unit" 
            parameter during initialization.
            The JEST servlet is mapped to URL pattern /jest/* in servlet mapping section. 
            So to access JEST servlet, use the following URI
            Notice the trailing forward slash character is significant.	

Copyright © 2006,2021 The Apache Software Foundation. Licensed under Apache License 2.0.
Apache, the Apache feather logo and OpenJPA are trademarks of The Apache Software Foundation.
Other names may be trademarks of their respective owners.