Glassfish HowTo & Known Issues

The maintainer uses Ehcache in production with Glassfish. This chapter provides a Glassfish HOWTO.

Versions

Ehcache is used in production with Glassfish V1 and V2.

HowTo

HowTo Get A Sample Application using Ehcache packaged and Deployed to Glassfish

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:

  • a Glassfish installation.
  • a GLASSFISH_HOME environment variable defined.
  • $GLASSFISH_HOME/bin added to your PATH

    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 .

    See for a quickstart to Glassfish.

How to get around the EJB Container restrictions on thread creation

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>

How To Enable Read Behind Page Caching in Glassfish

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

Glassfish Known Issues

Ehcache page caching versions below Ehcache 1.3 get an IllegalStateException in Glassfish.

This issue was fixed in Ehcache 1.3.