Thursday May 06, 2010

Updating EclipseLink to a newer version in existing GlassFish V3 installation

GlassFish V3 ships with EclipseLink 2.0 binaries as JPA provider. If you need to update your existing GlassFish installation to a newer version of EclipseLink binaries, you will need to do following



  • Download newer version of EclipseLink binaries from http://www.eclipse.org/eclipselink/downloads/. Choose OSGI bundles from the available downloads

  • Replace following files under $GLASSFISH_HOME/glassfish/modules with corresponding jars you downloaded above


    • org.eclipse.persistence.antlr.jar

    • org.eclipse.persistence.jpa.jar

    • org.eclipse.persistence.asm.jar

    • org.eclipse.persistence.jpa.modelgen.jar

    • org.eclipse.persistence.core.jar

    • org.eclipse.persistence.oracle.jar

    • javax.persistence.jar


  • Restart GlassFish

Monday Mar 02, 2009

Using Hibernate as JPA Provider for GlassFish V3

GlassFish V3 prelude ships with EclipseLink as the default JPA provider. The question that frequently gets asked is: How hard it is to to use Hibernate as the persistence provider with Glassfish V3. The answer is:  Not at all :). It is even simpler to achieve this than it was with V2. Thanks to the wonderful V3 update center it is as easy as 1-2-3. Lets  walk through the steps:

1. Download and install GlassFish V3 prelude with update tool.

2.  Launch the update tool. Hibernate is available under "Available Add-ons" as can be seen below. Check "Hibernate JPA" and click install.


3. GlassFish will be ready to use Hibernate as JPA provider[1]. The file <installdir>/hibernate/overview.txt contains all the information to get you started.

[1] Please note that we had used Derby 10.4.2.1 (also available with the update tool) for testing.


Wednesday May 30, 2007

Using Apache OpenJPA with GlassFish


Last year Sahoo blogged about using OpenJPA with GlassFish. OpenJPA has evolved a lot since then. It has graduated from incubator to a top level project at Apche. It is also passing JPA TCK. I tried to use OpenJPA with Glassfish V2 . It was very easy to do so. Here are the steps I followed

Step 1: Downnload and install GlassFish
Download any of the latest builds of GlassFish v2 or v1_ur1 from here. Install it in any directory of your choice. I refer to that as GLASSFISH_HOME

Step #2: Install OpenJPA
Download a nightly snapshot of OpenJPA 1.0.0 from here. Unzip this to any location. In this blog, I refer to that location as OPENJPA_HOME.

Step #3: Install OpenJPA in GlassFish
All you need to do is to make OpenJPA implementation jar files and its runtime dependency files available to GlassFish runtime. This can be achieved as follows:

    cd $OPENJPA_HOME
    cp openjpa-1.0.0-SNAPSHOT.jar lib/commons-\*.jar lib/serp-1.11.0.jar $GLASSFISH_HOME/domains/domain1/lib 

GlassFish will automatically make this jar part of its classpath next time when you restart the server. Please note that $OPENJPA_HOME/lib/geronimo\*.jar are not required to be copied as GlassFish already contains equivalent jars. Same is true for $OPENJPA_HOME/lib/derby\*.jar

Step #4: Edit persistence.xml
Make a one line change to your persistence.xml to instruct GlassFish
that we want to use OpenJPA as the persistence provider for this
application. This is achieved by setting the provider element to org.apache.openjpa.persistence.PersistenceProviderImpl. Shown below is a sample persistence.xml:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name ="em1">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<properties>
<!-- Enable SQL Logging for OpenJPA -->
<property name="openjpa.Log" value="DefaultLevel=INFO,SQL=TRACE"/>
</properties>
</persistence-unit>
</persistence>

Step #5: Build and deploy your app
Now you can build your Java EE application and deploy it to GlassFish.

About

Mitesh Meswani

Search

Categories
Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today
Bookmarks