Eclipse:尝试在Wildfly上创建Factory时“无法连接到任何服务器”

时间:2015-05-27 00:54:37

标签: java eclipse server wildfly factory-pattern

我在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)

有什么问题?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

尝试从我的代码连接JBoss时遇到了确切的错误日志。一旦我使用jboss-client.jar删除了构建路径中的所有其他jar,此问题就解决了。