尝试回收异常时使用spring-boot-starter-jta-atomikos抛出错误

时间:2016-11-08 02:54:23

标签: spring spring-boot activemq atomikos

我使用spring-boot(版本是1.4.1.RELEASE),spring-boot-starter-jta-atomikos和activemq都是由autoconfig设置的,我还添加连接池属性,如

# The maximum size of the pool.
spring.jta.atomikos.connectionfactory.max-pool-size=15
# The minimum size of the pool
spring.jta.atomikos.connectionfactory.min-pool-size=10

但是当添加连接池属性时,它会抛出异常,如

2016-11-08 05:30:07 [WARN] Slf4jLogger- atomikos connection pool 'jmsConnectionFactory': error while trying to recycle java.util.NoSuchElementException
    at java.util.ArrayList$Itr.next(ArrayList.java:834)
    at com.atomikos.jms.AtomikosJmsConnectionProxy.isInactiveInTransaction(AtomikosJmsConnectionProxy.java:383)
    at com.atomikos.jms.AtomikosPooledJmsConnection.canBeRecycledForCallingThread(AtomikosPooledJmsConnection.java:165)
    at com.atomikos.datasource.pool.ConnectionPool.recycleConnectionIfPossible(ConnectionPool.java:127)
    at com.atomikos.datasource.pool.ConnectionPool.findExistingOpenConnectionForCallingThread(ConnectionPool.java:184)
    at com.atomikos.datasource.pool.ConnectionPool.borrowConnection(ConnectionPool.java:149)
    at com.atomikos.jms.AtomikosConnectionFactoryBean.createConnection(AtomikosConnectionFactoryBean.java:616)
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.access$100(AbstractPollingMessageListenerContainer.java:75)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer$MessageListenerContainerResourceFactory.createConnection    (AbstractPollingMessageListenerContainer.java:484)
    at org.springframework.jms.connection.ConnectionFactoryUtils.doGetTransactionalSession(ConnectionFactoryUtils.java:312)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:280)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:235)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055)
    at java.lang.Thread.run(Thread.java:745)

如何解决这个问题?感谢

1 个答案:

答案 0 :(得分:0)

更新atomikos版本从3.9.3到4.0.4后,此警告消失

        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jta-atomikos</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.atomikos</groupId>
                <artifactId>transactions-jms</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.atomikos</groupId>
                <artifactId>transactions-jta</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.atomikos</groupId>
                <artifactId>transactions-jdbc</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.atomikos</groupId>
        <artifactId>transactions-jms</artifactId>
        <version>4.0.4</version>
    </dependency>
    <dependency>
        <groupId>com.atomikos</groupId>
        <artifactId>transactions-jta</artifactId>
        <version>4.0.4</version>
    </dependency>
    <dependency>
        <groupId>com.atomikos</groupId>
        <artifactId>transactions-jdbc</artifactId>
        <version>4.0.4</version>
    </dependency>