Description
Describe the bug
Using the EclipseLink Database Change Notification feature in combination with a wrapped Connection leads to a ClassCastException in OracleChangeNotificationListener:
java.lang.ClassCastException: class com.zuplyx.jpa.bugtest.connection.ConnectionWrapper cannot be cast to class oracle.jdbc.OracleConnection (com.zuplyx.jpa.bugtest.connection.ConnectionWrapper and oracle.jdbc.OracleConnection are in unnamed module of loader 'app')
at org.eclipse.persistence.platform.database.oracle.dcn.OracleChangeNotificationListener.register(OracleChangeNotificationListener.java:98)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:923)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:811)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:259)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:770)
To Reproduce
Steps/resources to reproduce the behavior:
- EclipseLink version: 4.0.5
- Java/JDK version: 21
A full reproducer can be found here
Expected behavior
The ClassCastException should not occur. Instead of blindly casting the connection, it would be better to use unwrap
Metadata
Metadata
Assignees
Labels
No labels