2012-11-05 33 views
0

我在使用java发布到ActiveMQ上的JMS主题时遇到问题。我的代码是非常基本的,但我得到了和error.The问题似乎发生时,我尝试发送一个消息:发布到ActiveMQ上的主题

ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url); 

ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection(); 
connection.start(); 

ActiveMQSession session = (ActiveMQSession) connection.createSession(false,Session.AUTO_ACKNOWLEDGE); 
Topic topic = ((TopicSession) session).createTopic(subject); 
ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(topic); 


ActiveMQTextMessage txtmessage = (ActiveMQTextMessage) session.createTextMessage(); 
txtmessage.setText(readFileAsString("foo.txt",null)); 


producer.send(txtmessage); 

Producer.send不发送短信,我收到以下错误:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.activemq.ActiveMQMessageProducerSupport.getDestination()Ljavax/jms/Destination; 

回答

0
java.lang.NoSuchMethodError: org.apache.activemq.ActiveMQMessageProducerSupport.getDestination()Ljavax/jms/Destination; 

NoSuchMethodError始终是您在客户端类路径中有客户罐子的错误版本(或者更低版本(或)更高版本)指示。

+0

@JimGarrison:我认为如果jar完全不存在,我认为它会是ClassNotFoundException,不是吗?如果可能,你能提供任何参考来支持你的评论吗? – kosa