I receive a ClassCastException when using Eclipselink's DescriptorCustomizer for History.
My customizer class looks like:
public class MyCustomizer implements DescriptorCustomizer {
@Override
public void customize(ClassDescriptor classDescriptor) thorws Exception {
// Setting HistoryPolicy here.
}
}
The entity is annotated with:
@Customizer(full.packagename.MyCustomizer.class)
This is done in the EJB module in a Maven project that is structured like:
- root
- ear
- ejb
- war
The Eclipslink dependency is:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.3</version>
<scope>provided</scope>
</dependency>
The code is running on WebSphere Liberty 17.0.0.2 on which there are no other applications deployed. The Eclipselink jar is in the server's global lib directory.
When the Eclipselink is first trying to access the entity I receive the following exception:
MyCustomizer cannot be cast to org.eclipse.persistence.config.DescriptorCustomizer
I tried to include the Eclipselink in the application's package but the result is the same. What can prevent the proper casting and how can I fix it?
EDIT #1
I changed the eclipselink dependency to:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.6.3</version>
<scope>provided</scope>
</dependency>
Since it does not contain the javax.persistence package thus it can not interfere with the Websphere's internal.
If I am doing manual casting in the application for testing purposes then there is no exception thrown. The ClassCastException is thrown when the getCriteriaBuilder() is called on the EntityManager.