The problem here is that JPA 2.0 is provided at runtime by the container. Exclusion of the provided dependency in pom.xml
has effect only at compile time. To solve this problem you must configure class loading in the container.
OpenShift JavaEE 6 support is based on JBoss AS 7. From Class Loading in AS7 documentation:
jboss-deployment-structure.xml is a JBoss specific deployment
descriptor that can be used to control class loading in a fine grained
manner. It should be placed in the top level deployment, in META-INF
(or WEB-INF for web deployments). It can do the following:
Prevent automatic dependencies from being added
Add additional dependencies
...
So what you need is to add a custom jboss-deployment-structure.xml
file to exclude hibernate-jpa-2.0-api
from being added automatically.
Based on OpenShift's documentation:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="javax.persistence.api" />
</exclusions>
</deployment>
</jboss-deployment-structure>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…