John M
John M

Reputation: 320

AbstractMethodError on entityManager.createQuery()

Using GlassFish 4 Stack trace looks like this

Caused by: java.lang.AbstractMethodError
at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:197)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:455)
at com.wellpoint.mobility.aggregation.core.configuration.impl.ConfigurationManagerImpl.loadConfiguration(ConfigurationManagerImpl.java:262)

Here are the hibernate jars, which from googling this problem I gather are relevant.

hibernate-commons-annotations-4.0.2.Final.jar
hibernate-core-4.2.15.Final.jar
hibernate-entitymanager.4.2.15.Final.jar
hibernate-jpa-2.0-api.1.0.1.Final.jar

According to another question I saw on this same exception hibernate JPA 2.0 should work with hibernate versions > 3.5. Vague recollections of math classes tell me that 4.2.15 > 3.5, so presumably I shouldn't be having these problems. Any thoughts?

Upvotes: 3

Views: 643

Answers (1)

Vlad Mihalcea
Vlad Mihalcea

Reputation: 153730

GlassFish 4 uses Java EE 7, so therefore you should use JPA 2.1 instead of JPA 2.0.

According to Hibernate docs this is the compatibility suite:

  • JPA 1.0: ORM 3.2+

  • JPA 2.0: ORM 3.5+

  • JPA 2.1: ORM 4.3+

So you should use Hibernate 4.3 with JPA 2.1:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.7.Final</version>
</dependency>

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.1-api</artifactId>
    <version>1.0.0.Final</version>
</dependency>

Upvotes: 1

Related Questions