Tuesday, June 13, 2017

JPA, EclipseLink and Hibernate as a persistence provider

a customer was getting
 weblogic.management.DeploymentException: 

 java.lang.ClassCastException: org.eclipse.persistence.jpa.jpql.parser.NullExpression 
cannot be cast to org.eclipse.persistence.jpa.jpql.parser.IdentificationVariable
 at org.eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.java:626)
 at org.eclipse.persistence.jpa.jpql.parser.RangeVariableDeclaration.accept(RangeVariableDeclaration.java:98)
 at org.eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.java:577)
 at org.eclipse.persistence.jpa.jpql.parser.IdentificationVariableDeclaration.accept(IdentificationVariableDeclaration.java:71)
 at org.eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.java:566)


using eclipselink.jar version 2.5.2 as part of the WLS distribution.
he finally made it work by using
weblogic-application.xml :

<prefer-application-packages>
  <package-name>com.google.collections</package-name>
  <package-name>com.google.common</package-name>
  <package-name>org.hibernate.*</package-name>
  <package-name>javax.validation</package-name>
</prefer-application-packages>



change the pom.xml to get extra dependency
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-validator</artifactId>
  <version>5.3.5.Final</version>
</dependency>




and in persistence.xml
<provider>org.hibernate.ejb.HibernatePersistence</provider>





No comments: