The maintainer uses Ehcache in production with Glassfish. This chapter provides a Glassfish HOWTO.
Ehcache is used in production with Glassfish V1 and V2.
Ehcache comes with a sample web application which is used to test the page caching. The page caching is the only area that is sensitive to the Application Server. For Hibernate and general caching, it is only dependent on your Java version.
From a checkout of ehcache run the following from the core directory:
You need:
Do the following:
# To package and deploy to domain1:
ant deploy-default-web-app-glassfish
# Start domain1:
asadmin start-domain domain1
# Stop domain1:
asadmin stop-domain domain1
# Overwrite the config with our own which changes the port to 9080:
ant glassfish-configuration
# Start domain1:
asadmin start-domain domain1
You can then run the web tests in the web package or point your browser at http://localhost:9080 .
When ehcache is running in the EJB Container, for example for Hibernate caching, it is in technical breach of the EJB rules. Some app servers let you override this restriction.
I am not exactly sure how this in done in Glassfish. For a number of reasons we run Glassfish without the Security Manager, and we do not have any issues.
In domain.xml ensure that the following is not included.
<jvm-options>-Djava.security.manager</jvm-options>
The read behind page caching feature requires that HTTP1.1 keepalives are turned off.
To do this in Glassfish:
Not sure if this is possible in Glassfish. Not in the documentation
This issue was fixed in Ehcache 1.3.