Spring ActiveMQ Caused By: javax.jms.IllegalStateException: Connection closed

Posted YSHY

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring ActiveMQ Caused By: javax.jms.IllegalStateException: Connection closed相关的知识,希望对你有一定的参考价值。

根据 http://www.cnblogs.com/yshyee/p/7448808.html 进行JMS操作时,发送跟监听放到不同的项目中进行时,出现以下异常信息:

org.springframework.jms.IllegalStateException: Connection closed; nested exception is javax.jms.IllegalStateException: Connection closed
        at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:279)
        at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
        at org.springframework.jms.core.JmsTemplate.executeLocal(JmsTemplate.java:987)
        at org.springframework.jms.core.JmsTemplate.sendAndReceive(JmsTemplate.java:913)
        at org.springframework.jms.core.JmsTemplate.sendAndReceive(JmsTemplate.java:904)
        Truncated. see log file for complete stacktrace
Caused By: javax.jms.IllegalStateException: Connection closed
        at org.apache.activemq.jms.pool.PooledConnection.assertNotClosed(PooledConnection.java:206)
        at org.apache.activemq.jms.pool.PooledConnection.start(PooledConnection.java:94)
        at org.springframework.jms.connection.SingleConnectionFactory$SharedConnectionInvocationHandler.localStart(SingleConnectionFactory.java:632)
        at org.springframework.jms.connection.SingleConnectionFactory$SharedConnectionInvocationHandler.invoke(SingleConnectionFactory.java:569)
        at com.sun.proxy.$Proxy189.start(Unknown Source)
        Truncated. see log file for complete stacktrace

解决方法:

修改 amqConnectionFactory配置如下:

    <!-- ActiveMQ 连接工厂 -->
    <bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL">
            <value>${amq.broker.url}</value>
        </property>
        <property name="userName">
            <value>${amq.username}</value>
        </property>
        <property name="password">
            <value>${amq.password}</value>
        </property>
    </bean>

 

以上是关于Spring ActiveMQ Caused By: javax.jms.IllegalStateException: Connection closed的主要内容,如果未能解决你的问题,请参考以下文章

1.spring异常:Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor(示例

Spring循环依赖问题如何解决?Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException

Spring Boot:Caused by: org.apache.ibatis.binding.BindingException: Parameter 'deptId' not fo

spring-cloud-alibaba-sentinel和feign配合使用,启动报Caused by: java.lang.AbstractMethodError: com.alibaba.clo

Caused by com microsoft sqlserver jdbc SQLServerException

Maven + Spring + Hibernate:hibernate3-maven-plugin hbm2ddl 失败,原因是“Caused by: java.lang.NullPointerEx