
JPA on GlassFish
Introduction #
This document provides the configuration details to setup the JPA when running on GlassFish V2. It is assumed that the Liferay is already installed on GlassFish V2 server.
Summary #
The Configuration includes two parts
- Instrumentable Class Loader for GlassFish
- Configuring JPA with Spring's GlassFish Load Time Weaver
Stop Server #
Stop the GlassFish server if it is running.
Instrumentable Class Loader for GlassFish #
The GlassFish server has support for Instrumentable Class Loader and it works only for EAR Environment. As Liferay is a web application the GlassFish must be configured with a Class Loader that is capable of Instrumentation required by Spring.
Configure context.xml and copy into META-INF directory of the deployed web application directory. For example, /opt/glassfish/domains/domain1/applications/j2ee-modules/liferay-portal/META-INF
<Context path="/" ><Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/> </Context> }}}
Configure portal-ext.properties #
Configure portal-ext.properties with following parameters. Essentially, the following configuration enables JPA as persistence provider and informs JPA to use GlassFish related Load Time Weaver.
persistence.provider=jpatransaction.isolation.portal=-1 jpa.load.time.weaver=org.springframework.instrument.classloading.glassfish.GlassFishLoadTimeWeaver}}}
Copy the “spring-instrument-tomcat.jar” #
Copy the “spring-instrument-tomcat.jar” file into GlassFish's server lib. Assuming that the GlassFish is installed under /opt/glassfish, copy the file into /opt/glassfish/lib. The file can be found in the "lib/development" directory of Liferay source tree.
Start the Server #
Start the GlassFish Server.
NOTE: Please use the jdbc configuration as usual for your choice of database
Reference: http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/JPA+integration