CLI connect from Java program - Wildfly 16.0.1

168 views
Skip to first unread message

Charith Paranaliyanage

unread,
Feb 18, 2022, 1:25:57 PM2/18/22
to WildFly
Hello,

I am trying to connect to my local Wildfly cli from the java program.

```
CommandContext ctx = org.jboss.as.cli.CommandContextFactory.getInstance().newCommandContext("posuser", "test".toCharArray());
ctx.connectController("127.0.0.1", 9990);
String CLIcmd = "ls /host=master/server-config=server-one";
ModelControllerClient client = ctx.getModelControllerClient();
ModelNode commandRequest = ctx.buildRequest(CLIcmd);
ModelNode result = client.execute(commandRequest);
System.out.println(result);
```

I started Wildfly as follows,
```
.\bin\standalone.bat -b 0.0.0.0 -bmanagement 0.0.0.0 -c standalone-full.xml
```

I am getting following error, what could be the reason for this?
```  
Caused by: java.io.IOException: java.net.ConnectException: JBAS012144: Could not connect to remote://127.0.0.1:9990. The connection timed out
```



James Perkins

unread,
Feb 24, 2022, 11:05:22 AM2/24/22
to WildFly
It looks like you've likely got another server running. The error message JBAS012144 is from either JBoss AS 7 or JBoss EAP 6.x.

Jean Francois Denise

unread,
Feb 28, 2022, 5:34:16 AM2/28/22
to wil...@googlegroups.com
Hi,
as James noted there is an issue with the error message, so an unexpected server is running.
From your trace it seems that an attempt is made to connect using the legacy remote protocol. Could be caused by a mis-configuration of the bin/jboss-cli.xml file (in case it is found by your Java client application).
To connect to the default management http interface, I would call: ctx.connectController("remote+http://127.0.0.1:9990");
Just a note, you are starting a standalone server but the CLI command targets a domain server "ls /host=master/server-config=server-one"
Hope that helps.
JF
--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/ea4cf572-0c85-42b0-bbef-cb383dca585fn%40googlegroups.com.


Reply all
Reply to author
Forward
0 new messages