Upgrade Glassfish v2 to JPA 2.0?

I try to use Hibernate 3.5.5 with Spring HibernateJpaVendorAdapter on Glassfish V2, but I get the following exception when the Spring context is initialized:

java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode; 

in org.hibernate.ejb.util.LogHelper.logPersistenceUnitInfo (LogHelper.java:39) on org.hibernate.ejb.Ejb3Configuration.configure (Ejb3Configuration.java►17) on org.hibernate.ejb.HibernatePerentererentererentererentererenteristererenterermenteristererentererentererentererentererentererentererenterermenterererer : 73)

The problem is that Glassfish V2 uses JPA1.0, which loads along the server class path to hibernate-jpa-2.0-api-1.0.0.Final.jar, which comes with Hibernate. JPA 1.0 does not have the getSharedCacheModel method in PersistenceUnitInfo, but JPA 2.0 does this.

Is there a way to upgrade Glassfish V2 to use JPA 2.0 (or any other solution to this problem)?

Greetings

J

+7
orm jpa hibernate3 glassfish
source share
4 answers

You can try to place the JPA 2.0 jar in the directory /domain/lib/endorsed

+4
source share

Thanks for the guys. Putting jpa jar in / domain / lib / is ok for me.

Setup ...

 <sun-web-app error-url=""> <class-loader delegate="false"/> </sun-web-app> 

... didn't work for me, although it could just be because classes are part of javax.

I also tried cutting out the Spring JPATemplate and using the JPA @PersistenceContext EntityManager directly - this caused all kinds of problems. Glassfish v2 + Spring + Hibernate are not friends!

+1
source share

As far as I know, it is not possible to upgrade the Java EE core of 5 containers with the JPA core by simply replacing the libraries and using the JPA 2.0 container-driven EntityManager.

However, it should be possible to use the JPA 2.0 implementation with the JPA 2.0 API library provided at the application level and use the JPA 2.0 application-driven EntityManager.

To try the second approach with GlassFish v2, you need to disable classloader delegation (so that application libraries are used first). This can be configured in sun-web.xml , which you packaged in WEB-INF :

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd"> <sun-web-app error-url=""> <class-loader delegate="false"/> </sun-web-app> 
0
source share

Glassfish 2.1 does not support JPA 2, I downloaded the JPA 2 version and pasted it into the $GLASSFISH_HOME/lib/endorsed/ directory and pasted it into commons-loggin1.1.jar, and this works for me.

It looks like this:

/ glassfish / lib / approved by $ ls
activation.jar
OpenJPA-all-2.0.1.jar
General Logging 1.1.jar
webservices-api.jar

http://glassfish.java.net/public/comparing_v2_and_v3.html
http://openjpa.apache.org/downloads.html

0
source share

All Articles