Skip Headers
Oracle® Coherence Client Guide
Release 3.7.1

Part Number E22839-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

29 Deploying Coherence REST

This chapter provides instructions for deploying Coherence REST to an embedded HTTP server, WebLogic server, and GlassFish server. Generic servlet container instructions are also provided.

The following sections are included in this chapter:

29.1 Deploying with the Embedded HTTP Server

Coherence provides two embedded HTTP servers that can be used to host RESTful Web services: com.tangosol.coherence.rest.server.DefaultHttpServer (backed by Oracle's lightweight HTTP server) and com.tangosol.coherence.rest.server.GrizzlyHttpServer (backed by Grizzly). See "Changing the Embedded HTTP Server" for details on changing the default HTTP server.

The HTTP server must be enabled on a Coherence proxy server. To enable the HTTP server, edit the proxy's cache configuration file and add an <http-acceptor> element, within the <proxy-scheme> element, and include the host and port for the HTTP server.

The following example configures the HTTP server to accept requests on localhost 127.0.0.1 and port 8080.

<proxy-scheme>
   <service-name>ExtendHttpProxyService</service-name>
   <acceptor-config>
      <http-acceptor>
         <class-name>
            com.tangosol.coherence.rest.server.DefaultHttpServer</class-name>
         <local-address>
            <address>127.0.0.1</address>
            <port>8080</port>
         </local-address>
         <resource-config>
            <instance>
               <class-name>
                  com.tangosol.coherence.rest.server.DefaultResourceConfig
               </class-name>
            </instance>
         </resource-config>
      </http-acceptor>
   </acceptor-config>
   <autostart>true</autostart>
</proxy-scheme>

The above configuration explicitly defines the HTTP server class and Jersey resource configuration class. However; these are default values and need not be included. See Oracle Coherence Developer's Guide for a detailed reference of all <http-acceptor> subelements.

29.2 Deploying to a Java EE Server

This section provides instructions for deploying Coherence Rest to a Java EE environment:

The following topics are included in this section:

29.2.1 Packaging Coherence REST for Deployment

To package a Coherence REST application:

  1. Create a basic Web application directory structure as follows:

    /
    /WEB-INF
    /WEB-INF/classes
    /WEB-INF/lib
    
  2. Copy the following JARs from the COHERENCE_HOME/lib directory to the /WEB-INF/lib directory:

    • coherence.jar

    • coherence-rest.jar

    • jackson-all-1.8.1.jar

    • jersey-core-1.7.jar

    • jersey-json-1.7.jar

    • jersey-server-1.7.jar

  3. Create a Web application deployment descriptor (web.xml) and include the following servlet definition:

    <web-app>
       <servlet>
          <servlet-name>Coherence REST</servlet-name>
          <servlet-class>
             com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
          <init-param>
             <param-name>
                com.sun.jersey.config.property.resourceConfigClass</param-name>
               <param-value>
                  com.tangosol.coherence.rest.server.DefaultResourceConfig
                </param-value>
          </init-param>
          <load-on-startup>1</load-on-startup>
       </servlet>
          ...
    </web-app>
    
  4. Save the web.xml file to the /WEB-INF/ directory.

  5. Copy the coherence-rest-config.xml file to the /WEB-INF/classes directory.

  6. Copy your coherence-cache-config.xml file and tangosol-coherence-override.xml file to the WEB-INF/classes directory.

  7. Create a Web ARchive file (WAR) using the jar utility. For example, issue the following command from a command prompt at the root of the Web application directory:

    jar -cvf coherence_rest.war *
    

    The archive should contain the following files

    /WEB-INF/web.xml
    /WEB-INF/classes/coherence-rest-config.xml
    /WEB-INF/classes/tangosol-coherence-override.xml
    /WEB-INF/classes/coherence-cache-config.xml
    /WEB-INF/lib/coherence.jar
    /WEB-INF/lib/coherence-rest.jar
    /WEB-INF/lib/jackson-all-1.8.1.jar
    /WEB-INF/lib/jersey-core-1.7.jar
    /WEB-INF/lib/jersey-json-1.7.jar
    /WEB-INF/lib/jersey-json-1.7.jar
    

29.2.2 Deploying to WebLogic Server

To deploy Coherence REST to WebLogic server:

  1. Package Coherence REST as a WAR file as described in "Packaging Coherence REST for Deployment". To ensure the correct version of Coherence is used, add the following WebLogic-specific deployment descriptor to the /WEB-INF directory:

    <?xml version="1.0" encoding="UTF-8"?>
    <wls:weblogic-web-app
       xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
       http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
       http://xmlns.oracle.com/weblogic/weblogic-web-app 
       http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
       <wls:container-descriptor>
          <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
       </wls:container-descriptor>
    </wls:weblogic-web-app>
    
  2. Deploy the WAR using the WebLogic administration console (http://localhost:7001/console).

  3. From a browser, access the data in a Coherence cache by navigating to http://localhost:7001/{cacheName}.

29.2.3 Deploying to GlassFish

To deploy Coherence REST to GlassFish server:

  1. From GlassFish administration console, click Configuration->JVM Settings. switch to the JVM Options tab and add the following option:

  2. Click the JVM Options tab and add the following option:

    -Dcom.sun.enterprise.overrideablejavaxpackages=javax.ws.rs,javax.ws.rs.core,javax.ws.rs.ext

  3. Package Coherence REST as a WAR file as described in "Packaging Coherence REST for Deployment". In addition, override the version of Jersey distributed in GlassFish with the version of Jersey distributed with Coherence REST by setting the class loader delegation to false in WEB-INF/sun-web.xml or WEB-INF/glassfish-web.xml. For example:

    <sun-web-app error-url="">
       <class-loader delegate="false"/>
    </sun-web-app>
    
  4. Deploy the WAR using the GlassFish administration console. (http://localhost:4848/).

  5. From a browser, access the data in Coherence caches by navigating to http://localhost:8080/{cacheName}.

29.2.4 Deploying to a Servlet Container

Coherence REST can be deployed to any servlet container by packaging Coherence REST as a WAR file. See "Packaging Coherence REST for Deployment" for details. Refer to your vendors documentation for details on deploying WAR files. In addition, See the Jersey user guide for additional servlet container deployment options:

http://jersey.java.net/nonav/documentation/latest/user-guide.html#d4e194