This chapter provides details on how to use the Oracle Coherence archetypes to create, build, and deploy Oracle Coherence applications.
This chapter includes the following topics:
Introduction to Building Oracle Coherence Projects with Maven
Deploying Your Coherence Project to the WebLogic Server Coherence Container with Maven
A Maven plug-in and an archetype is provided for Oracle Coherence Grid Archive (GAR) projects. Table 11-1 describes the Maven coordinates.
Table 11-1 Maven Coordinates with Coherence
| artifacts | groupId | artifactId | version |
|---|---|---|---|
|
GAR Plugin |
|
|
|
|
GAR Archetype |
|
|
|
Table 11-2 describes the goals supported by the Oracle Coherence plug-in.
To create a new Coherence project using the Coherence Maven archetype, issue a command similar to the following:
mvn archetype:generate
-DarchetypeGroupId=com.oracle.coherence.archetype
-DarchetypeArtifactId=gar-maven-archetype
-DarchetypeVersion=12.2.1-0-0
-DgroupId=org.mycompany
-DartifactId=my-gar-project
-Dversion=1.0-SNAPSHOT
This command runs Maven's archetype:generate goal which lets you create a new project from an archetype. Table 11-3 describes the parameters.
Table 11-3 Parameters for the Coherence Projects
| Parameter | Purpose |
|---|---|
|
|
The group ID of the archetype that you want to use to create the new project. This must be |
|
|
The artifact ID of the archetype that you want to use to create the new project. This must be |
|
|
The version of the archetype that you want to use to create the new project. This must be |
|
|
The group ID for your new project. This usually starts with your organization's domain name in reverse format. |
|
|
The artifact ID for your new project. This is usually an identifier for this project. |
|
|
The version for your new project. This is usually |
You can also run the command without any arguments, as shown in the following example. In this case, Maven displays a list of available archetypes and prompts you to enter the required information.
mvn archetype:generate
After creating your project, it contains the following files:

Table 11-4 describes the files included in the project.
Table 11-4 Files Created for the Coherence Project
| File | Purpose |
|---|---|
|
|
The Maven Project Object Model (POM) file that describes your new project. It includes the Maven coordinates that you specified for your project and the appropriate plug-in definitions to use the Coherence Maven plug-in to build your project into a gar file. |
|
|
A starter Coherence cache configuration file. |
|
|
A starter Coherence GAR deployment descriptor for your GAR file. |
|
|
A starter Coherence Portable Object Format (POF) configuration file. The POF configuration file is processed and inserted into the final GAR file if the plug-in option |
If you are using POF in your project, you must add the following parameter into your project's POM file:
| Parameter | Purpose |
|---|---|
generatePof |
The POF configuration file is generated and inserted into the final GAR file if this plug-in option is true. The configuration file is generated by scanning all classes in the GAR's classpath annotated with the class com.tangosol.io.pof.annotation.Portable. By default, POF configuration metadata is not generated. |
To generate a GAR with correctly generated pof-config.xml, add the following to your GAR plug-in configuration in the POM:
<build>
<plugins>
…
<plugin>
<groupId>com.oracle.coherence</groupId>
<artifactId>gar-maven-plugin</artifactId>
<version>12.2.1-0-0</version>
<extensions>true</extensions>
<configuration>
<generatePof>true</generatePof>
</configuration>
</plugin>
…
</plugins>
</build>
After you have written your project code, you can use Maven to build the project:
To compile the source code in your project, execute the following command:
mvn compile
To package the compiled source into a GAR, execute the following command. Note that this command runs all steps up to package, including the compile.
mvn package
To deploy your GAR to a Coherence Container in a WebLogic Server environment, you must add some additional configuration to your project's POM file:
Add instructions to use the Oracle WebLogic Maven plug-in to deploy the GAR, as shown in the following example:
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>12.2.1-0-0</version>
<executions>
<!--Deploy the application to the server-->
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<adminurl>t3://localhost:7001</adminurl>
<user>weblogic</user>
<password>welcome1</password>
<!--The location of the file or directory to be deployed-->
<source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
<!--The target servers where the application is deployed-->
<targets>AdminServer</targets>
<verbose>true</verbose>
<name>${project.build.finalName}</name>
</configuration>
</execution>
</executions>
</plugin>
After you have added this section to your POM, use the following command to compile, package, and deploy your GAR to the WebLogic Server:
mvn verify
In a real application, you are likely to have not just a GAR project, but also some kind of client project that interacts with the Coherence cache established by the GAR. Refer to Chapter 15, "Building a Real Application with Maven" to see an example that includes a Coherence GAR and a web application (WAR) that interacts with it.