5
WrappedConnectionJDK6 wrapped = (WrappedConnectionJDK6) dbStrategy.getConnection();
            Connection underlyingConn = wrapped.getUnderlyingConnection();
            OracleConnection oracleConn = (OracleConnection)underlyingConn;

Last line gives Error -

> ERROR
> [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/web].[resteasy-servlet]]
> (http-/0.0.0.0:8080-1) Servlet.service() for servlet resteasy-servlet
> threw exception: org.jboss.resteasy.spi.UnhandledException:
> java.lang.ClassCastException: oracle.jdbc.driver.T4CConnection cannot
> be cast to oracle.jdbc.OracleConnection
HemChe
  • 2,249
  • 1
  • 21
  • 33
user2093576
  • 3,082
  • 7
  • 32
  • 43
  • and what is the question ? – Gab Apr 16 '13 at 10:20
  • 1
    Need to get oracle connection from WrappedConnectionJDK6 .. but its giving casting issue .. Any clue how to get oracle connection out of WrappedConnectionJDK6 ? – user2093576 Apr 16 '13 at 10:43
  • JBoss wraps the oracle connection with it's own one (org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6). I am trying to call #getUnderlyingConnection() to get the underlying connection. But while converting that into Oracle connection it is giving error... Connection Casting error – user2093576 Apr 17 '13 at 11:43

1 Answers1

6

AFAIK T4CConnection should implement oracle.jdbc.OracleConnection. IMHO you have 2 driver implementation, one on the app server and one in your project dependencies, there must be a classloading issue as the retrieved driver implementation is loaded by the shared class loader and you try to cast it to a class loaded by the webApp class loader.

You can ensure that your web-app dependency is the same than the server provided implementation or just exclude the dependency from the web app when packaging it.

If you're using maven just set the scope to provided.

Gab
  • 7,869
  • 4
  • 37
  • 68
  • it is provided still am facing same issue com.oracle ojdbc6 11.2.0.3 provided – user2093576 Apr 16 '13 at 12:07
  • ah, well honestly i don't know so. don't you have a transitive dependency somewhere ? – Gab Apr 16 '13 at 12:25
  • 1
    Actually I need to create - StructDescriptor.createDescriptor("SOMETHING", con); but as it is from oracle utility i can not pass the connection as sql connection.. So I need to convert T4CCon to Oracle.. and the casting is giving problem.. – user2093576 Apr 17 '13 at 11:45
  • Did you ensure server and webapp driver implementation are exactly the same ? – Gab Apr 17 '13 at 11:49
  • i have configured ojdbc6 as driver in console.. Am using JbossEAP6.. And i guess Jboss takes ironjacamar.. can that be the problem? – user2093576 Apr 17 '13 at 13:07
  • If you configured yourself the datasource, i suppose you provided the same lib. Maybe it can come from JCA but i don't think so. Did you have OracleDriver explicitely specified in DS configuration ? (oracle.jdbc.driver.OracleDriver) – Gab Apr 17 '13 at 13:13
  • whatever we configure in server console.. it is showing in stanalone.xml – user2093576 Apr 17 '13 at 13:24
  • ie - jdbc:oracle:thin:@x oracle.jdbc.OracleDriver ojdbc6.jar – user2093576 Apr 17 '13 at 13:25
  • Yes.. i had to remove the OJDBC6 jar.. There was no need to deploy it separately from Jboss server console.. Thanks Gab.. u had hit a bull's eye when u told "there must be a classloading issue as the retrieved driver implementation is loaded by the shared class loader and you try to cast it to a class loaded by the webApp class loader." Thanks bro.. u r life saver.. – user2093576 Apr 17 '13 at 16:58