gpt4 book ai didi

java - HornetQ - java.lang.NoClassDefFoundError : Lorg/hornetq/core/logging/Logger;

转载 作者:行者123 更新时间:2023-11-30 06:36:04 27 4
gpt4 key购买 nike

我正在尝试运行一本书(HornetQ Messaging Developers Guide)中的一个简单的 HornetQ 示例,但收到错误消息。我没有使用maven,因为我想坚持使用书中给出的示例。 HornetQ Standalone 服务器在命令行中正常启动。我只是想向 HonretQ 服务器发送消息。

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();





}

}

尽管我添加了书中提到的所有 jar ,但我收到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: Lorg/hornetq/core/logging/Logger;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredField(Unknown Source)
at java.io.ObjectStreamClass.getDeclaredSUID(Unknown Source)
at java.io.ObjectStreamClass.access$700(Unknown Source)
at java.io.ObjectStreamClass$2.run(Unknown Source)
at java.io.ObjectStreamClass$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.<init>(Unknown Source)
at java.io.ObjectStreamClass.lookup(Unknown Source)
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.hornetq.jms.referenceable.SerializableObjectRefAddr.deserialize(SerializableObjectRefAddr.java:79)
at org.hornetq.jms.referenceable.ConnectionFactoryObjectFactory.getObjectInstance(ConnectionFactoryObjectFactory.java:43)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(Unknown Source)
at chapter01.ECGMessageConsumerProducerExample.main(ECGMessageConsumerProducerExample.java:31)
Caused by: java.lang.ClassNotFoundException: org.hornetq.core.logging.Logger
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more

我还添加了一堆我发现与此主题相关的其他 jar,但没有解决问题。

Overview of Jars

错误产生的原因是什么?

最佳答案

您需要hornetq-core jar,下载并使用它

关于java - HornetQ - java.lang.NoClassDefFoundError : Lorg/hornetq/core/logging/Logger;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45189488/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com