gpt4 book ai didi

java - Eclipse:尝试通过 Wildfly 创建工厂时出现 "Failed to connect to any server"

转载 作者:太空宇宙 更新时间:2023-11-04 13:49:23 25 4
gpt4 key购买 nike

我在 Wildfly 的 standalone-full 文件中添加了一个连接工厂:

<jms-connection-factories>
<connection-factory name="K19Factory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="K19Factory"/>
<entry name="java:jboss/exported/jms/K19Factory"/>
</entries>
</connection-factory>
...
</jms-connection-factories>

还有 Eclipse 上使用它的代码。但我在创建工厂时遇到了问题:

 ConnectionFactory factory = (ConnectionFactory)ic.lookup("jms/K19Factory");

当尝试运行此行时,我收到以下错误:

Exception in thread "main" javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:87)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:129)
at javax.naming.InitialContext.lookup(Unknown Source)
at br.com.k19.emissores.EnviaNovoPedidoJBoss.main(EnviaNovoPedidoJBoss.java:30)

问题是什么?

最佳答案

Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
prop.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
prop.put("jboss.naming.client.ejb.context", true);
Context ctx = new InitialContext(prop);

关于java - Eclipse:尝试通过 Wildfly 创建工厂时出现 "Failed to connect to any server",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30471398/

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