Accueil‎ > ‎

Migrating WebApp from GlassFish to TomEE

posted 10 May 2019, 03:26 by Christophe Noël   [ updated 17 Jun 2019, 02:14 ]
Some usual requirements:
  • Create a WEB-INF/resources.xml  (see below) for replacing glassfish-resources.xml
  • Update persistence.xml provider:  <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
  • Update persistence.xml provider: remove jdbc  in jta-data-source
  • Also add <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>



<?xml version="1.0" encoding="UTF-8"?>
<resources>
  <Resource id="processing-scheduler-ds" type="javax.sql.DataSource">
jdbcDriver=org.postgresql.Driver
password=xxx
userName=xxx
jdbcUrl=jdbc\:postgresql\://localhost\:5432/xxx
</Resource>
</resources>

In pom.xml, replace EclipseLink provided libs with the following (in some cases this is required otherwise the generated classes files are not correct and it will try to find an EclipseLink jpa provider at runtime!):

<dependency>
    <groupId>org.apache.tomee</groupId>
    <artifactId>openejb-jpa-integration</artifactId>
    <version>7.1.0</version>
    <scope>provided</scope>
</dependency>

You also need to add "openjpa.jdbc.SynchronizeMappings" property for ensuring the load scripts are executed.

<property name="javax.persistence.schema-generation.database.action" value="create"/>
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
      <property name="javax.persistence.sql-load-script-source"
            value="META-INF/import.sql" />
Comments