-->

oracle.jdbc.driver.T4CConnection不能转换为oracle.jdbc.O

2019-08-31 07:43发布

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

最后行给出了错误 -

> 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

Answer 1:

据我所知T4CConnection应该实现oracle.jdbc.OracleConnection。 恕我直言,你有2个驱动程序实现,一个应用程序服务器上,一个在你的项目依赖,必须有作为检索到的驱动程序实现是通过共享的类加载器加载的类加载问题,并尝试将其转换为通过web应用程序加载的类类加载器。

您可以确保您的web应用程序的依赖超过了服务器提供的实现相同或只是包装时,它排除了Web应用程序的依赖。

如果你正在使用maven刚才设置的范围provided



文章来源: oracle.jdbc.driver.T4CConnection cannot be cast to oracle.jdbc.OracleConnection