Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » problem when migrating from oracle11 to oracle12e(Getting ClassCast Exception when migrating from oracle11 to oracle12e)
problem when migrating from oracle11 to oracle12e [message #1763638] Thu, 18 May 2017 09:25 Go to next message
Avinash TS is currently offline Avinash TSFriend
Messages: 3
Registered: May 2017
Junior Member
Hi ,

I have spent lot of time on fixing the above issue , still i don't have any clue .So i just want to make sure whether we can use Eclipselink jar to connect oracle 12 db or not .

I have tried various version of eclipselink. No use

it works fine with Oracle 11 and ojdbc14.jar

And now we are working on migrating to oracle12 and i tried using ojdbc 7 and ojdbc 6 jars.

Please find my project configurations below

1. Java 1.8

2. Spring 3.2.1 Realease

3. Ojdbc7.jar (am using it now )

with these configurations am gettinf below exception .please find it below

2017/05/18 09:13:58.299 [RMI TCP Connection(8)-10.197.6.152]: AUDIT- ERROR: Error while invoking a client call: saveOrUpdateItvApplicationAggregate. Error is: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: java.lang.ClassCastException: org.apache.commons.dbcp.PoolableConnection cannot be cast to oracle.jdbc.OracleConnection
[Exception: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: java.lang.ClassCastException: org.apache.commons.dbcp.PoolableConnection cannot be cast to oracle.jdbc.OracleConnection
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:522)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:755)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:387)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:51)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy67.saveOrUpdateItvApplicationAggregate(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:77)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy69.saveOrUpdateItvApplicationAggregate(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:205)
at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:38)
at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:78)
at org.springframework.remoting.rmi.RmiBasedExporter.invoke(RmiBasedExporter.java:73)
at com.cab.infra.highavailability.rmi.exporter.InfraRmiServiceExporter.invoke(InfraRmiServiceExporter.java:254)
at org.springframework.remoting.rmi.RmiInvocationWrapper.invoke(RmiInvocationWrapper.java:72)
at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.persistence.RollbackException: java.lang.ClassCastException: org.apache.commons.dbcp.PoolableConnection cannot be cast to oracle.jdbc.OracleConnection
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:157)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:513)
... 46 more
=======================================================


Please help me out to resolve this issue. And please confirm EclipseLink can be used to connect Oracle12 or not suppirted ?


Thanks in Advance.

[Updated on: Mon, 22 May 2017 05:18]

Report message to a moderator

Re: problem when migrating from oracle11 to oracle12e [message #1763682 is a reply to message #1763638] Thu, 18 May 2017 14:23 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
EclipseLink works fine against any Oracle database I know of. The error here is from Spring's wrapping of the connections when EclipseLink is expecting an Oracle connection directly - this should be the same regardless of the drivers being used, so you'll have to check the settings within the application and in the persistence.xml for differences.

Good luck.
Chris

[Updated on: Thu, 18 May 2017 14:26]

Report message to a moderator

Re: problem when migrating from oracle11 to oracle12e [message #1763741 is a reply to message #1763682] Fri, 19 May 2017 09:06 Go to previous messageGo to next message
Avinash TS is currently offline Avinash TSFriend
Messages: 3
Registered: May 2017
Junior Member
Hello Chris ,

Thanks for the quick response.

Could you please share the ideal settings of eclipse link for connecting to oracle12 db .

Since it was working for ojdbc14 and oracle 11 , Am not finding what difference would be there to connect to oracle 12 g.

Please find the persistence XML file below

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<properties>
<!-- Default database login using Oracle for EclipseLink's internal connection pool,
change this to access your own database. -->
<!-- property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:xxxx:xxxxx" />
<property name="javax.persistence.jdbc.user" value="xxxxx" />
<property name="javax.persistence.jdbc.password" value="xxxxx" /-->

<!-- The database platform is auto-detected by default,
if you want to set a specific platform this can be set. -->
<!-- property name=""eclipselink.target-database" value="Oracle" / -->

<!-- Optimize database writes to use batching. -->
<property name="eclipselink.jdbc.batch-writing" value="JDBC" />

<!-- Avoids flush being triggered before every query execution. -->
<property name="eclipselink.persistence-context.flush-mode" value="AUTO" />

<!-- Configure connection pool. -->
<property name="eclipselink.jdbc.connections.initial" value="1" />
<property name="eclipselink.jdbc.connections.min" value="64" />
<property name="eclipselink.jdbc.connections.max" value="64" />

<!-- In JSE no server platform is used, if you wish to use this example is a JEE server with JTA,
then you need to set this. -->
<!-- property name="eclipselink.target-server" value="WebLogic" / -->

<!-- Configure cache size. -->
<property name="eclipselink.cache.size.default" value="1000" />
<!-- If desired, this option would disable caching. -->
<property name="eclipselink.cache.shared.default" value="false"/>

<!-- If desired, this option would force a JDBC connection to be held for the duration of an EntityManager,
instead of returned to the pool in between queries/transactions. -->
<!-- property name="eclipselink.jdbc.exclusive-connection.mode" value="Always" / -->

<!-- Configure database to be created on startup if not already existing. -->
<!-- property name="eclipselink.ddl-generation" value="create-tables" /-->
<!-- To drop and replace existing schema this can be used. -->
<!-- property name="eclipselink.ddl-generation" value="drop-and-create-tables" / -->

<!-- Configure simple SQL logging for demonstration. -->
<property name="eclipselink.logging.level" value="OFF" />
<property name="eclipselink.logging.thread" value="false" />
<property name="eclipselink.logging.session" value="false" />
<property name="eclipselink.logging.exceptions" value="false" />
<property name="eclipselink.logging.timestamp" value="false" />

<!-- Configure custom Id generator. -->
<property name="eclipselink.session.customizer" value="com.cabpersistence.custom.eclipselink.UUIDSequence"/>

<!-- Configure custom descriptor customizers (for history support, could also be achieved using @Customizer annotation). -->
<!-- property name="eclipselink.descriptor.customizer.ItvModuleEntity" value="com.persistence.custom.eclipselink.RolloutPlanHistoryCustomizer"/>
<property name="eclipselink.descriptor.customizer.ItvContentEntity" value="com.persistence.custom.eclipselink.RolloutPlanHistoryCustomizer"/-->
</properties>
</persistence-unit>
</persistence>


Thanks again.

[Updated on: Mon, 22 May 2017 05:26]

Report message to a moderator

Re: problem when migrating from oracle11 to oracle12e [message #1764088 is a reply to message #1763741] Wed, 24 May 2017 16:16 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
There is more to the exception stack that is cut off that might show why EclipseLink is trying to cast the connection to an Oracle one. What might be different between your instances is that you explicitly commented out the <!-- property name=""eclipselink.target-database" value="Oracle" / --> and relied on Auto detection. I don't know what platform was detected for your earlier working version - EclipseLink logging would tell you - but chances are the metadata for the drivers is returning something different, causing the new drivers to use a later Oracle database platform and is trying to take advantage of Oracle specific features not available on the Spring connection wrapper.

You can either write a server platform that handles the connection unwrapping ( see https://www.eclipse.org/eclipselink/api/2.6/org/eclipse/persistence/platform/server/ServerPlatformBase.html and https://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_target_server.htm ) Or set the target database to be what was used previously - likely just by uncommenting the eclipselink.target-database property and using Oracle.
Re: problem when migrating from oracle11 to oracle12e [message #1764124 is a reply to message #1764088] Thu, 25 May 2017 11:04 Go to previous message
Avinash TS is currently offline Avinash TSFriend
Messages: 3
Registered: May 2017
Junior Member

It worked :) I have just added the property <property name=""eclipselink.target-database" value="Oracle" /> .

Thank you Chris . Really you saved my day .


Previous Topic:Difference between Dynamic vs Static weaving in Weblogic 12c
Next Topic:Eclipselink PerformanceProfiler Not Thread Safe
Goto Forum:
  


Current Time: Fri Mar 29 13:24:19 GMT 2024

Powered by FUDForum. Page generated in 0.03205 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top