oracle.jdbc.driver.T4CConnection cannot be cast to oracle.jdbc.OracleConnection

StackOverflow https://stackoverflow.com/questions/16033652

  •  04-04-2022
  •  | 
  •  

문제

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
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top