遗憾的是,在尝试使用HornetQ处理JMS服务时,我正在运行表单错误消息以显示错误消息。先前的错误与缺少core.jar文件有关。
但是,我收到以下错误消息:
线程main中的异常java.lang.NoSuchMethodError:org.hornetq.api.core.client.ClientSessionFactory.copy()Lorg / hornetq / api / core / client / ClientSessionFactory; at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:612) at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:116) at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:111) at chapter01.ECGMessageConsumerProducerExample.main(ECGMessageConsumerProducerExample.java:33)我预计错误是由服务器使用的jar和客户端使用的jar不匹配引起的。但由于我是程序员菜鸟,我真的不知道需要哪些适合的版本的罐子。
解决方案尝试定义NettyConnectorFactory作为中的连接器jboss参考。
例如在hornetq-configuration.xml文件中:
< ;连接器及GT; < connector name =netty> < factory-class> org.hornetq.core.remoting.implty.NettyConnectorFactory < / factory-class> < param key =portvalue =5446/> < / connector> < / connectors>
unfortunately while trying to get a JMS service working with HornetQ, I am running form error message to error message. The prior error was related to a missing core.jar file. Prior Error
After all, I am trying to implement a simple producer/consumer example as a jms service. (Based on "HornetQ Messaging Developer's Guide")
package chapter01; import javax.jms.JMSException; import javax.naming.NamingException; public class ECGMessageConsumerProducerExample { public static void main(String[] args) throws NamingException, JMSException { // TODO Auto-generated method stub javax.naming.Context ic = null; javax.jms.ConnectionFactory cf = null; javax.jms.Connection connection = null; javax.jms.Queue queue = null; javax.jms.Session session = null; com.mongodb.Mongo m; com.mongodb.DB db; String destinationName = "queue/DLQ"; java.util.Properties p = new java.util.Properties(); p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); p.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); p.put(javax.naming.Context.PROVIDER_URL, "jnp://localhost:1099"); ic = new javax.naming.InitialContext(p); cf = (javax.jms.ConnectionFactory)ic.lookup("/ConnectionFactory"); queue = (javax.jms.Queue)ic.lookup(destinationName); connection = cf.createConnection(); session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); connection.start(); String theECG = "1;02/20/2012 14:01:59.010;1020,1021,1022"; javax.jms.MessageProducer publisher = session.createProducer(queue); javax.jms.TextMessage message = session.createTextMessage(theECG); publisher.send(message); System.out.println("Message sent!"); publisher.close(); } }While facing erros I probably added unneeded jars:
However, I get the following error message:
Exception in thread "main" java.lang.NoSuchMethodError: org.hornetq.api.core.client.ClientSessionFactory.copy()Lorg/hornetq/api/core/client/ClientSessionFactory; at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:612) at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:116) at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:111) at chapter01.ECGMessageConsumerProducerExample.main(ECGMessageConsumerProducerExample.java:33)I expect the error to be caused by a mismatch between jars used by the server and used by the client. But since I am a programmer noob, I do not really know what exact jars with suitable versions are needed.
解决方案Try defining NettyConnectorFactory as connector as in jboss reference.
for example in hornetq-configuration.xml file:
<connectors> <connector name="netty"> <factory-class> org.hornetq.core.remoting.implty.NettyConnectorFactory </factory-class> <param key="port" value="5446"/> </connector> </connectors>
更多推荐
HornetQ JMS:java.lang.NoSuchMethodError
发布评论