28 Jan 2012

OpenJPA 2.2.0 and Glassfish 3.1.1

Written by ilgrosso

Syncope recently gained official support for Glassfish 3.1.1: since the JPA layer did - again recently - move to Apache OpenJPA, we faced some issues when trying to deploy Syncope - as OpenJPA-powered web application - to Glassfish.

Some tips that finally made us succeeding:

  • Enhance your Entity classes at build time
  • Do not delegate class loading
  • If you have RESTful DELETE services, allow DELETE method for JSPs
  • Kindly ask embedded EclipseLink not to try to dinamycally weave your Entity classes for a couple of good reasons:
    • you are using OpenJPA not EclipseLink
    • your Entity classes were enhanced at build time - see above
  • Try to avoid @ManyToMany bidirectional relationships by refactoring your source code - this could be a temporary bug of OpenJPA 2.2.0, as reported in dev mailing list

Basically, you have to add the following property to persistence.xml:

<property name="eclipselink.weaving" value="false"/>

and to create a file called glassfish-web.xml with the following content under WEB-INF folder:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
    <class-loader delegate="false"/>
        <property name="httpMethods" value="GET,POST,HEAD,PUT,DELETE"/>

That's all :-)


« Return