users@glassfish.java.net

Re: GF3 + OpenJPA 2.0 - Enhancer not working

From: Mitesh Meswani <mitesh.meswani_at_oracle.com>
Date: Tue, 20 Jul 2010 00:47:39 -0700

  On 7/19/2010 6:09 AM, glassfish_at_javadesktop.org wrote:
> Hello,
>
> I have a Glassfishv3 running here and *need* to use OpenJPA-2.0.0.
>
> I'm currently having two different setups in our persistence.xml; here's the working one:
>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
>
> <persistence-unit name="myApplicationPersistenceUnit" transaction-type="RESOURCE_LOCAL">
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> <jta-data-source>jdbc/MyDataSource</jta-data-source>
> <properties>
> <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/>
> <!--<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/> -->
> </properties>
> </persistence-unit>
> </persistence>
This seems to indicate that you are using JavaSE style (that is calling
Persistence.createEMF() ) to instantiate your EMF. Here the container
does not get chance to communicate with Open JPA to install the
necessary hooks to enable enhancements. You will need to fall back to
statically enhance as you are doing currently with this mode.

> Now, we want to use Glassfish's automatic Enhancer support, as there seems to be a requirement to do so for JavaEE 5 compatible app servers (see: http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_pc_enhance.html#ref_guide_pc_enhance_runtime_container).
>
> As the just copying the openjpa lib (plus required serp-1.13.1 library) to Glassfish's\domains\domain1\lib directory doesn't seem to help, I installed the OSGi-compatible packages (it also requires commons-lang-2.4.0, commons-collections-3.2.1, commons-logging-1.1.1, commons-pool-1.5.3 as well as serp-1.13.1; all obtained from springsource.com) and used the following persistence.xml:
>
Just copying all the libs required by OpenJPA to the lib dir should
work. What issue do you get when you do this?

-Mitesh