DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. Data
  4. GlassFish 3.1 with Oracle Coherence for Java Version 3.7

GlassFish 3.1 with Oracle Coherence for Java Version 3.7

Markus Eisele user avatar by
Markus Eisele
·
Apr. 20, 11 · Interview
Like (0)
Save
Tweet
Share
6.51K Views

Join the DZone community and get the full member experience.

Join For Free

Yesterday, Oracle released the latest evolution of Coherence, their flagship, distributed in-memory data grid product Oracle Coherence 3.7. Coherence 3.7 simplifies the configuration and management of large-scale deployments and provides more data storage capabilities and intelligent and dynamic load balancing of client connections. The new Elastic Data feature introduces breakthrough technology that enables the use of both memory and disk-based devices for data grid storage, enabling near memory speed access to data, regardless of storage medium, and greater flexibility in capacity and resource planning.

It also introduces dynamic load balancing and automatic proxy discovery for Coherence*Extend clients (for example, application servers or desktop applications accessing the Oracle Coherence data grid). It also integrates with F5 BIG-IP Load Traffic Manager (LTM) and SSL Acceleration technologies to take advantage of existing infrastructures to secure, optimize and load balance application traffic. Coherence configuration files are now described using XML schema definitions (XSD) and are no longer described using Document Type Definition (DTD).
Last but not least Coherence 3.7 finally introduces the native integration with GlassFish Server by using the Coherence*Web SPI for GlassFish (ActiveCache for GlassFish), providing "no code change" installation and configuration of Coherence*Web, making it dramatically easier for GlassFish Server users to scale their applications. And that's exactly what we are going to do today.

Preparation
Get the latest Oracle GlassFish Server 3.1. Unzip/install it to your favorite location. Download Oracle Coherence for Java Version 3.7. Same here: Unzip to your favorite location. Open the coherence_3.7\lib\webInstaller.jar and extract the webInstaller.jar\web-install\coherence-web.jar and the session-cache-config.xml. Now you have to create a domain if you haven't already (asadmin create-domain coherenceTest). Copy the coherence.jar from coherence_3.7\lib\ to your domain\lib folder.

Configuring
If you are starting from scratch, you have to fire up your favorite IDE and create a new Web or Ear Project. If you are configuring a web project, copy the coherence-web.jar file to the /WEB-INF/lib/ directory of your Web application. If you are configuring an ear project, copy the coherence-web.jar file to the EAR file's /lib. The session-cache-config.xml needs to be in your /WEB-INF/classes folder.
For this simple example I refer to the good old clusterjsp (taken from Arun's Screencast #34). Extract it. Put coherence-web.jar into ear/lib folder and create a WEB-INF/classes folder in which you put the session-cache-config.xml file. Great. Delete the sun-web.xml from WEB-INF and create a new glassfish-web.xml containing:
<glassfish-web-app>
<session-config>
<session-manager persistence-type="coherence-web" />
</session-config>
<glassfish-web-app>
Done. Package everything up again.

Start a Cache Server
A Coherence data node (also known as a cache server) is responsible for storing and managing all cached data. It can be run either in a dedicated JVM (out-of-process) or within a GlassFish Server instance (in-process). The simplest setting is to run it in-process. To make this easy you have to edit the config/domain.xml and add a JVM Option:
<jvm-options>-Dtangosol.coherence.session.localstorage=true</jvm-options>
Now fire up your GlassFish and deploy the sample. If you are looking at the server.log you see Oracle Coherence coming up and logging some fancy stuff:
Oracle Coherence Version 3.7.0.0 Build 23397
 Grid Edition: Development mode
...
  Clustered Session Cache Name=session-storage
  Local Session Cache Name=local-session-storage
  Local Session Attribute Cache Name=local-attribute-storage
  Death Certificate Cache Name=session-death-certificates
  SessionDistributionController Class Name=com.tangosol.coherence.servlet.glassfish31.GlassFishHybridController
  AttributeScopeController Class Name=com.tangosol.coherence.servlet.AbstractHttpSessionCollection$ApplicationScopeController
...
That's good. Now you know, that everything is working.

Start your GlassFish and deploy the application
Now you can start the application and use it as normal. This doesn't make too much sense if you are running everything on one node only. You should try to configure a complete cluster with at least one node and two or even more instances to experience the session replication. This very basic example makes use of all the defaults present for Coherence*Web Cache and cluster configuration. If necessary, you can provide an alternate cache and cluster configuration in your own custom session-cache-config.xml and tangosol-coherence-override.xml file. You must include the file in the WEB-INF/classes. Please refer to the complete documentation (see links below) for details.

Links and Further Readings
High performance JPA with GlassFish and Coherence
Oracle® Coherence User's Guide for Oracle Coherence*Web
Installing Oracle Coherence for Java
Using Coherence*Web with GlassFish Server
Installing and Configuring Eclipse and OEPE with Coherence

Screencasts
The GlassFish Product Manager Adam Leftik published two screencasts about the concepts behind Oracle Coherence and how Active Cache for GlassFish provides seamless integration with Coherence*Web. This is great additional information if you need to know more about the whole topic.

Active Cache For GlassFish Part 1 of 2


Active Cache For GlassFish Part 2 of 2

 

From http://blog.eisele.net/2011/04/glassfish-31-with-oracle-coherence-for.html

Oracle Coherence Coherence (units of measurement) GlassFish Java (programming language) application Data (computing)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Spring Boot, Quarkus, or Micronaut?
  • Introduction to Containerization
  • The Power of Docker Images: A Comprehensive Guide to Building From Scratch
  • Introduction to Container Orchestration

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: