日期:2014-05-19  浏览次数:20835 次

JMS 创建连接报错
如上。
报错如下。
Java code


log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:292)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:539)
    at com.mq.queue.spring.ProducerServiceImpl.send(ProducerServiceImpl.java:42)
    at com.mq.queue.spring.ProducerTest.send(ProducerTest.java:12)
    at com.mq.queue.spring.ProducerTest.main(ProducerTest.java:19)
Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
    at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:295)
    at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:239)
    at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:185)
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:461)
    ... 4 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:504)
    at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:467)
    at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:54)
    at org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:121)
    at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
    at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72)
    at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
    at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
    at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:275)
    ... 8 more





------解决方案--------------------