我有一个java应用程序,我调用Oracle过程并将Oracle数组作为参数传递。我的申请是EAR。
在Java 7和Jboss 7上一切正常,但是当我们升级到Java 8和Wildfly 10时,我们遇到了这个错误:
java.lang.ClassCastException:
org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast
to org.jboss.jca.adapters.jdbc.WrappedConnection
经过一番研究后,我将代码更改为:
WrappedConnectionJDK7 wc = (WrappedConnectionJDK7 ) conn;
OracleConnection oraconn = (OracleConnection) wc.getUnderlyingConnection();
我在pom.xml中添加了依赖
<dependency>
<groupId>org.jboss.ironjacamar</groupId>
<artifactId>ironjacamar-jdbc</artifactId>
<version>1.3.2.Final</version>
</dependency>
但我仍然收到此错误:
java.lang.ClassCastException:
org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast to
org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7
答案 0 :(得分:1)
我在EAR / META-INF中添加了jboss-deployment-structure.xml,它解决了这个问题。
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<sub-deployment name="myapp.jar">
<dependencies>
<module name="org.jboss.ironjacamar.jdbcadapters" />
<module name="com.oracle.db" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
答案 1 :(得分:0)
我之前必须打开类似的连接(但不是完全相同的包装类)并使用过:
OracleConnection oconn;
if ( conn.isWrapperFor( OracleConnection.class ) )
{
oconn = (OracleConnection) conn.unwrap( OracleConnection.class );
}
else
{
throw new SQLException( "Not an Oracle Connection" );
}