HornetQ JMS:java.lang.NoSuchMethodError

编程入门 行业动态 更新时间:2024-10-10 00:26:10
本文介绍了HornetQ JMS:java.lang.NoSuchMethodError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

遗憾的是,在尝试使用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

本文发布于:2023-11-25 11:38:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629593.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JMS   HornetQ   java   NoSuchMethodError   lang

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!