Issues with Native Client
rwlarsen Sep 13, 2017 12:16 PMI am attempting to read a portion of the Wildfly config from within a deployed application. I'm following the documentation found here:
https://docs.jboss.org/author/display/WFLY10/The+native+management+API
Wildfly will not start with the line (from the documentation):
<
native
-
interface
interface
=
"management"
port=
"9999"
security-realm=
"ManagementRealm"
/>
in <management><managemeent-interfaces> as the "interface" and "port" attributes aren't recognized. I've replaced that with:
<native-interface security-realm="ManagementRealm">
<socket-binding native="management-native"/>
</native-interface>
and added
<socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
to <socket-binding-group>.
Wildfly seems happy with this configuration, and starts without error, and is listening on port 9999.
However the client is not able to connect:
java.net.ConnectException: JBAS012144: Could not connect to remote://hostname.local:9999. The connection timed out
The code being executed is based on the code in the documentation:
final CallbackHandler handler = (Callback[] callbacks) -> {
for (Callback cb : callbacks) {
if (cb instanceof NameCallback) {
NameCallback ncb = (NameCallback) cb;
ncb.setName("username");
} else if (cb instanceof PasswordCallback) {
PasswordCallback pwcb = (PasswordCallback) cb;
pwcb.setPassword("password".toCharArray());
} else if (cb instanceof RealmCallback) {
RealmCallback rcb = (RealmCallback) cb;
rcb.setText("ManagementRealm");
} else {
throw new UnsupportedCallbackException(cb);
}
}
};
try (ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getLocalHost(), 9999, handler)) {
final ModelNode op = new ModelNode();
op.get("operation").set("read-resource");
ModelNode address = op.get("address");
address.set("subsystem", "keycloak");
op.get("recursive").set(true);
final ModelNode result = client.execute(op);
if (Operations.isSuccessfulOutcome(result)) {
System.out.println(result.get("result").toString());
} else {
throw new RuntimeException(Operations.getFailureDescription(result).asString());
}
}
The relevant portion of the pom is:
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-controller-client</artifactId>
<version>7.2.0.Final</version>
</dependency>
I'm not sure if this is an issue with the config or with the code, since I cannot get a connection at all. Any help would be greatly appreciated.