How to connect JBoss 7.1.1 remoting-jmx via java code?

I have a JBoss 7.1.1 server for which I want to write a jmx client. As I understand it, jboss 7.1.1 does not use typical rmi-based jmx, and they gave a remoting-jmx layer on top of their own control. I am using the following code:

JMXServiceURL address = new JMXServiceURL("service:jmx:remoting-jmx://localhost:9999");

Map env = JMXConnectorConfig.getEnvironment(paramtbl);

JMXConnector connector = JMXConnectorFactory.connect(address, env);

But this gives the following exception:

java.net.MalformedURLException: Unsupported protocol: remoting-jmx

I searched for it and the following thread seems relevant: https://community.jboss.org/thread/204653?tstart=0

He asks to add jboss libraries to my classpath. I tried this too, but still getting the same exception.

+4
source share
5 answers

JmxServiceUrl. , standalone.xml :

<subsystem xmlns="urn:jboss:domain:jmx:1.1"> <show-model value="true"/> <remoting-connector use-management-endpoint="true" /> </subsystem>

class jar : jboss-client.jar, JBOSS_DIRECTORY/bin/client. , JMX- jar .

. , .

+10

JBoss

ModelControllerClient client = null;
try {
 client = createClient(InetAddress.getByName("172.16.73.12"), 9999,
     "admin", "pass", "ManagementRealm");
    } 
catch (UnknownHostException e) {
 e.printStackTrace();
}

createClient - , -

private ModelControllerClient createClient(final InetAddress host,
  final int port, final String username, final String password,
  final String securityRealmName) {

 final CallbackHandler callbackHandler = new CallbackHandler() {

  public void handle(Callback[] callbacks) throws IOException,
    UnsupportedCallbackException {
   for (Callback current : callbacks) {
    if (current instanceof NameCallback) {
     NameCallback ncb = (NameCallback) current;
     ncb.setName(username);
    } else if (current instanceof PasswordCallback) {
     PasswordCallback pcb = (PasswordCallback) current;
     pcb.setPassword(password.toCharArray());
    } else if (current instanceof RealmCallback) {
     RealmCallback rcb = (RealmCallback) current;
     rcb.setText(rcb.getDefaultText());
    } else {
     throw new UnsupportedCallbackException(current);
    }
   }
  }
 };
 return ModelControllerClient.Factory
   .create(host, port, callbackHandler);
}

, , , API Java/Google ( 10 ), -

http://javacodingtutorial.blogspot.com/2014/05/reading-jboss-memory-usage-using-java.html

+1

Arquillian JBoss AS7 , , :

import org.jboss.remotingjmx.RemotingConnectorProvider;

RemotingConnectorProvider s = new RemotingConnectorProvider();
JMXConnector connector = s.newJMXConnector(url, credentials);
connector.connect();

"module name=" org.jboss.remoting-jmx "services =" import "" working

environment.put("jmx.remote.protocol.provider.pkgs", "org.jboss.remotingjmx");
JMXConnector connector = JMXConnectorFactory.connect(url, environment);
connector.connect();
+1

jboss-deployment- :

 

   <dependencies>
         <module name="org.jboss.remoting3.remoting-jmx" services="import"/>
   </dependencies>

0

JMX, standalone.xml

<subsystem xmlns="urn:jboss:domain:ee:1.1">
  <!-- Activate JMX remoting -->
  <global-modules>
    <module name="org.jboss.remoting-jmx" slot="main"/>
  </global-modules>
  ...
</subsystem>
0

Source: https://habr.com/ru/post/1533278/


All Articles