jboss eap 错误 org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8 无法转换为 oracle.jdbc.internal.OracleConnection
jboss eap error org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8 cannot be cast to oracle.jdbc.internal.OracleConnection
我正在开发骆驼路由以连接到 Jboss EAP Fuse 上的 Oracle AQ。
我设法使用连接工厂做到了,如下所示:
<bean class="org.apache.camel.component.jms.JmsComponent" id="oracleAQQueue">
<property name="connectionFactory" ref="oracleQueueAQCredentials"/>
</bean>
<bean
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"
id="oracleQueueAQCredentials" primary="true">
<property name="targetConnectionFactory">
<ref bean="connectionFactoryOracleAQAQQueue"/>
</property>
</bean>
<bean class="oracle.jms.AQjmsFactory"
factory-method="getQueueConnectionFactory" id="connectionFactoryOracleAQAQQueue">
<constructor-arg index="0">
<value>jdbc:oracle:thin:xx/xx@localhost:1521/orclpdb</value>
</constructor-arg>
<constructor-arg index="1" type="java.util.Properties">
<value/>
</constructor-arg>
</bean>
接下来我要做的是在 Jboss EAP 上使用 JNDI 数据源而不是连接字符串。
所以我在 jboss
上配置了数据源
<datasource jta="true" jndi-name="java:/AQ_DB" pool-name="AQ_DB_DataSource" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:@localhost:1521/orclpdb</connection-url>
<driver>oracle</driver>
<security>
<user-name>xx</user-name>
<password>xx</password>
</security>
</datasource>
<driver name="oracle" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
然后我更改我的代码以使用如下连接:
<jee:jndi-lookup id="jndiConnectionFactory" jndi-name="java:/AQ_DB" />
<bean class="oracle.jms.AQjmsFactory"
factory-method="getQueueConnectionFactory" id="connectionFactoryOracleAQAQQueue">
<constructor-arg index="0">
<ref bean="jndiConnectionFactory"/>
</constructor-arg>
</bean>
然而,在启动 Jboss EAP 时,显示以下错误。
Cause: Error creating the db_connection; nested exception is java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8 cannot be cast to oracle.jdbc.internal.OracleConnection: oracle.jms.AQjmsException: Error creating the db_connection
at oracle.jms.AQjmsDBConnMgr.getConnection(AQjmsDBConnMgr.java:625)
at oracle.jms.AQjmsDBConnMgr.<init>(AQjmsDBConnMgr.java:399)
at oracle.jms.AQjmsConnection.<init>(AQjmsConnection.java:259)
at oracle.jms.AQjmsConnectionFactory.createConnection(AQjmsConnectionFactory.java:529)
at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.doCreateConnection(UserCredentialsConnectionFactoryAdapter.java:181)
at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.createConnection(UserCredentialsConnectionFactoryAdapter.java:152)
at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180)
at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:411)
at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:396)
at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:927)
at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:901)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1079)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8 cannot be cast to oracle.jdbc.internal.OracleConnection
at oracle.jms.AQjmsGeneralDBConnection.getProviderKey(AQjmsGeneralDBConnection.java:99)
at oracle.jms.AQjmsGeneralDBConnection.<init>(AQjmsGeneralDBConnection.java:68)
at oracle.jms.AQjmsDBConnMgr.getConnection(AQjmsDBConnMgr.java:566)
有人可以帮忙吗?
您需要打开连接,因为它来自 ironjacamar 池。
谢谢你,ehsavoie。你给我指明了正确的方向。
所以我必须扩展 oracle class 来提供解决方案:
private class OracleAqGetUnderlyingConnectionFactory extends AQjmsConnectionFactory {
private DataSource dataSource;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public javax.jms.Connection createConnection() throws javax.jms.JMSException {
WrappedConnectionJDK8 connection = null;
OracleConnection underlyingOracleConnection = null;
try {
connection = (WrappedConnectionJDK8) dataSource.getConnection();
underlyingOracleConnection = (OracleConnection) connection.getUnderlyingConnection();
} catch (SQLException e) {
e.printStackTrace();
}
return AQjmsQueueConnectionFactory.createQueueConnection(underlyingOracleConnection);
}
}
我正在开发骆驼路由以连接到 Jboss EAP Fuse 上的 Oracle AQ。 我设法使用连接工厂做到了,如下所示:
<bean class="org.apache.camel.component.jms.JmsComponent" id="oracleAQQueue">
<property name="connectionFactory" ref="oracleQueueAQCredentials"/>
</bean>
<bean
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"
id="oracleQueueAQCredentials" primary="true">
<property name="targetConnectionFactory">
<ref bean="connectionFactoryOracleAQAQQueue"/>
</property>
</bean>
<bean class="oracle.jms.AQjmsFactory"
factory-method="getQueueConnectionFactory" id="connectionFactoryOracleAQAQQueue">
<constructor-arg index="0">
<value>jdbc:oracle:thin:xx/xx@localhost:1521/orclpdb</value>
</constructor-arg>
<constructor-arg index="1" type="java.util.Properties">
<value/>
</constructor-arg>
</bean>
接下来我要做的是在 Jboss EAP 上使用 JNDI 数据源而不是连接字符串。 所以我在 jboss
上配置了数据源<datasource jta="true" jndi-name="java:/AQ_DB" pool-name="AQ_DB_DataSource" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:@localhost:1521/orclpdb</connection-url>
<driver>oracle</driver>
<security>
<user-name>xx</user-name>
<password>xx</password>
</security>
</datasource>
<driver name="oracle" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
然后我更改我的代码以使用如下连接:
<jee:jndi-lookup id="jndiConnectionFactory" jndi-name="java:/AQ_DB" />
<bean class="oracle.jms.AQjmsFactory"
factory-method="getQueueConnectionFactory" id="connectionFactoryOracleAQAQQueue">
<constructor-arg index="0">
<ref bean="jndiConnectionFactory"/>
</constructor-arg>
</bean>
然而,在启动 Jboss EAP 时,显示以下错误。
Cause: Error creating the db_connection; nested exception is java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8 cannot be cast to oracle.jdbc.internal.OracleConnection: oracle.jms.AQjmsException: Error creating the db_connection
at oracle.jms.AQjmsDBConnMgr.getConnection(AQjmsDBConnMgr.java:625)
at oracle.jms.AQjmsDBConnMgr.<init>(AQjmsDBConnMgr.java:399)
at oracle.jms.AQjmsConnection.<init>(AQjmsConnection.java:259)
at oracle.jms.AQjmsConnectionFactory.createConnection(AQjmsConnectionFactory.java:529)
at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.doCreateConnection(UserCredentialsConnectionFactoryAdapter.java:181)
at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.createConnection(UserCredentialsConnectionFactoryAdapter.java:152)
at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180)
at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:411)
at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:396)
at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:927)
at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:901)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1079)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8 cannot be cast to oracle.jdbc.internal.OracleConnection
at oracle.jms.AQjmsGeneralDBConnection.getProviderKey(AQjmsGeneralDBConnection.java:99)
at oracle.jms.AQjmsGeneralDBConnection.<init>(AQjmsGeneralDBConnection.java:68)
at oracle.jms.AQjmsDBConnMgr.getConnection(AQjmsDBConnMgr.java:566)
有人可以帮忙吗?
您需要打开连接,因为它来自 ironjacamar 池。
谢谢你,ehsavoie。你给我指明了正确的方向。
所以我必须扩展 oracle class 来提供解决方案:
private class OracleAqGetUnderlyingConnectionFactory extends AQjmsConnectionFactory {
private DataSource dataSource;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public javax.jms.Connection createConnection() throws javax.jms.JMSException {
WrappedConnectionJDK8 connection = null;
OracleConnection underlyingOracleConnection = null;
try {
connection = (WrappedConnectionJDK8) dataSource.getConnection();
underlyingOracleConnection = (OracleConnection) connection.getUnderlyingConnection();
} catch (SQLException e) {
e.printStackTrace();
}
return AQjmsQueueConnectionFactory.createQueueConnection(underlyingOracleConnection);
}
}