在localhost上拒绝JBoss EAP7 ModelControllerClient连接

时间:2017-08-31 17:51:50

标签: jboss

我正在编写一个JBoss EAR应用程序,它需要查询正在运行的本地JBoss服务器以获取部署状态。我独立运行JBoss。我可以使用JBoss-CLI轻松查询JBoss服务器,但是使用带有' ModelControllerClient'的API,我得到一个"连接被拒绝"错误。我的防火墙已完全禁用,我指的是localhost,所以我不确定问题是什么。

以下是我正在运行的代码:

public static void GetStatus() throws Exception{

    ModelNode operation = new ModelNode();
    operation.get( "address" ).add( "deployment", "*" );
    operation.get( "operation" ).set( "read-attribute" );

    ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getByName("127.0.0.1"), 9990);
    ModelNode result = client.execute( new OperationBuilder(operation).build() );

    List<ModelNode> deployments = result.get( "result" ).asList();
    String deploymentName;

    // finally we can iterate and get the deployment names.
    for ( ModelNode deployment : deployments ) {
        deploymentName = deployment.get( "result" ).asString();
        System.out.println( "deploymentName = " + deploymentName );
    }
}

...这是调用此方法时收到的错误:

java.io.IOException: java.net.ConnectException: JBAS012144: Could not connect to remote://localhost:9990. The connection timed out

如果我运行netstat -tuna命令,我看到我正在听0:0:0:0:9990

谢谢!

1 个答案:

答案 0 :(得分:0)

尝试在localhost上启动服务器而不是0.0.0.0。另请参阅http://middlewaremagic.com/jboss/?p=2676

中的示例示例