从ActiveMQXASslConnectionFactory实例创建XAConnection实例失败

时间:2019-07-04 16:09:38

标签: java activemq

我在服务器端启用了通过SSL连接的传输,我想创建到服务器的SSL连接。从ActiveMQXASslConnectionFactory实例创建XAConnection实例失败。这是我的代码:

ActiveMQXASslConnectionFactory sslConnectionFactory = new ActiveMQXASslConnectionFactory(mqUrl);
try {
    sslConnectionFactory.setKeyStore("file:" + keystoreFile);
    sslConnectionFactory.setKeyStorePassword(keystorePassword);
    sslConnectionFactory.setTrustStore("file:" + truststoreFile);
    sslConnectionFactory.setTrustStorePassword(truststorePassword);
} catch (Exception ex) {
}

XAConnection connection = sslConnectionFactory.createXAConnection();

当我运行示例代码时,它会引发异常:

Exception in thread "main" java.lang.NoSuchFieldError: xaAckMode
        at org.apache.activemq.ActiveMQXASslConnectionFactory.configureXAConnection(ActiveMQXASslConnectionFactory.java:84)
        at org.apache.activemq.ActiveMQXASslConnectionFactory.createActiveMQConnection(ActiveMQXASslConnectionFactory.java:79)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:266)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:238)
        at org.apache.activemq.ActiveMQXASslConnectionFactory.createXAConnection(ActiveMQXASslConnectionFactory.java:48)

这是一个错误吗?请帮忙。

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。 pom.xml中有不同版本的依赖关系。我将其删除并成功执行了代码。