gpt4 book ai didi

java - 没有 J2EE 容器的 JNDI(有 JNP?也许是其他供应商?)

转载 作者:搜寻专家 更新时间:2023-10-31 19:36:31 25 4
gpt4 key购买 nike

我需要在没有 J2EE 容器开销的情况下运行 JNDI 提供程序。我已尝试按照此 article 中的说明进行操作,它准确地描述了(在第 3 页上)我想做什么。不幸的是,这些指示失败了。我也必须将 jboss-common.jar 添加到我的类路径中。一旦我这样做了,我就会得到一个堆栈跟踪:

$ java org.jnp.server.Main
0 [main] DEBUG
org.jboss.naming.Naming - Creating
NamingServer stub, theServer=null,rmiPort=0,clientSocketFactory=null,serverSocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad093076[bindAddress=null]
Exception in thread "main"
java.lang.NullPointerException
at org.jnp.server.Main.getNamingInstance(Main.java:301)
at org.jnp.server.Main.initJnpInvoker(Main.java:354)
at org.jnp.server.Main.start(Main.java:316)
at org.jnp.server.Main.main(Main.java:104)

我希望能够完成这项工作,但我也愿意接受其他轻量级独立 JNDI 提供程序。所有这一切都是为了让 ActiveMQ 工作,如果有人可以建议另一个轻量级的 JMS 提供者,它在 vm 之外运行良好,客户端在没有一个完整的应用程序服务器的情况下也可以工作。

最佳答案

Apache ActiveMQ已经带有集成的轻量级 JNDI 提供程序。参见 these instructions on using it .

基本上,您只需将 jndi.properties 文件添加到类路径即可。

java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory

# use the following property to configure the default connector
java.naming.provider.url = failover:tcp://localhost:61616

# use the following property to specify the JNDI name the connection factory
# should appear as.
#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = example.MyQueue


# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic

关于java - 没有 J2EE 容器的 JNDI(有 JNP?也许是其他供应商?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/192718/

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