|Oracle® Coherence Developer's Guide
Part Number E15723-03
This chapter provides instructions for deploying Coherence into a runtime environment.
The following sections are included in this chapter:
Standalone applications that leverage Coherence must include the
/lib/coherence.jar library on the application's classpath. This scenario assumes the application is using the default Coherence configuration included within the archive. If a configuration override file is used, then the directory that includes the override file must also be included in the classpath. For more information on modifying the default configuration, see Chapter 3, "Understanding Configuration."
The following example starts an application called
MyApp. The classpath includes the
coherence.jar library as well as the location (
COHERENCE_HOME) that contains a
tangosol-coherence-override.xml configuration file.
java -jar -cp COHERENCE_HOME;COHERENCE_HOME\lib\coherence.jar com.MyApp
Java EE applications that leverage Coherence have two options for deploying Coherence: as an application server library or as part of a Java EE module. Each option results in a different deployment scenario because Coherence cluster nodes are class loader scoped. This means each module can have access to is own Coherence node or all modules can share a single Coherence node. Each option has its own benefits and assumptions and generally balances resource utilization with how isolated the cluster node is from other modules.
Note:This section does not include instructions for deploying Coherence*Web. See the Oracle Coherence*Web User's Guide for instructions on deploying Coherence*Web and clustering HTTP session data.
Coherence can be deployed as an application server library. In this deployment scenario, an application server's startup classpath is modified to include the
/lib/coherence.jar library. In addition, any objects that are being placed into the cache must also be available in the server's classpath. Consult your application server vendor's documentation for instructions on adding libraries to the server's classpath.
This scenario results in a single Coherence node that is shared by all applications that are deployed in the server's containers. This scenario minimizes resource utilization because only one copy of the Coherence classes is loaded into the JVM. This scenario is ideal if all applications being deployed in a server are known and development teams carefully coordinate and enforce cache conventions and naming standards.
Note:This scenario should be considered very carefully and never used in application servers where application interaction is unknown or unpredictable. In this deployment scenario, all applications are part of the same cluster and the likelihood of collisions between namespaces for caches, services and other configuration settings is high and may lead to unexpected results. All applications may be affected by any one application's use of the Coherence node.
Coherence can be deployed within an EAR file or a WAR file. This style of deployment is generally preferred because modification to the application server runtime is not required and because cluster nodes are isolated to either the EAR or WAR.
Coherence can be deployed as part of an EAR. This deployment scenario results in a single Coherence cluster node that is shared by all Web applications in the EAR. Resource utilization is moderate because only one copy of the Coherence classes will be loaded per EAR. However, all Web applications may be affected by any one module's use of the Coherence node. This option is ideal when deploying a single EAR to an application server.
To deploy Coherence within an enterprise application:
coherence.jar library to a location within the enterprise application directory structure.
Using a text editor, open the
META-INF/application.xml deployment descriptor.
<java> element that contains the path (relative to the top level of the application directory) and name of the coherence library. For example:
<application> <display-name>MyApp</display-name> <module> <java>coherence.jar</java> </module> ... </application>
Make sure any objects that are to be placed in the cache are added to the application in the same manner as described above.
Save and close the descriptor.
package and deploy the application.
Coherence can be deployed as part of a Web application. This deployment scenario results in each Web application having its own Coherence node in the cluster, which is isolated from all other Web applications. This scenario utilizes the most amount of resources because there will be as many copies of the Coherence classes loaded as there are deployed Web applications that include Coherence. This scenario is ideal when deploying only a few Web applications to an application server.
To deploy Coherence within a Web application:
coherence.jar library to the Web Application's
Make sure any objects that are to be placed in the cache are located in either the
Package and deploy the application.