IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java Discussion :

Problème mbeans jmx


Sujet :

Java

  1. #1
    Membre habitué Avatar de wiss85
    Homme Profil pro
    Inscrit en
    Novembre 2009
    Messages
    90
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Tunisie

    Informations forums :
    Inscription : Novembre 2009
    Messages : 90
    Points : 184
    Points
    184
    Par défaut Problème mbeans jmx
    j'utilise jdevloper 11g
    Dans l’exécution de mon programme j’ai les erreurs suivants :
    Create an RMI connector client and connect it to the RMI connector server
    java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: server
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:323)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
    at pack.Client.main(Client.java:25)
    Caused by: javax.naming.NameNotFoundException: server
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:99)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1871)
    at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1841)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
    ... 2 more
    Process exited with exit code 0.



    et voici mon class :

    package pack;

    import java.io.IOException;
    import java.util.Iterator;
    import java.util.Set;
    import javax.management.Attribute;
    import javax.management.MBeanServerConnection;
    import javax.management.MBeanServerInvocationHandler;
    import javax.management.ObjectName;
    import javax.management.remote.JMXConnector;
    import javax.management.remote.JMXConnectorFactory;
    import javax.management.remote.JMXServiceURL;

    public class Client {

    public static void main(String[] args) {
    try {
    // Create an RMI connector client and
    // connect it to the RMI connector server
    //
    echo("\nCreate an RMI connector client and " +
    "connect it to the RMI connector server");
    JMXServiceURL url = new JMXServiceURL(
    "service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/server");
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

    // Create listener
    //
    ClientListener listener = new ClientListener();

    // Get an MBeanServerConnection
    //
    echo("\nGet an MBeanServerConnection");
    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
    waitForEnterPressed();

    // Get domains from MBeanServer
    //
    echo("\nDomains:");
    String domains[] = mbsc.getDomains();
    for (int i = 0; i < domains.length; i++) {
    echo("\tDomain[" + i + "] = " + domains[i]);
    }
    waitForEnterPressed();

    // Get MBeanServer's default domain
    //
    String domain = mbsc.getDefaultDomain();

    // Create SimpleStandard MBean
    //
    ObjectName stdMBeanName =
    new ObjectName(domain +":type=SimpleStandard,index=2");
    echo("\nCreate SimpleStandard MBean...");
    mbsc.createMBean("SimpleStandard", stdMBeanName, null, null);
    waitForEnterPressed();

    // Create SimpleDynamic MBean
    //
    ObjectName dynMBeanName =
    new ObjectName(domain +":type=SimpleDynamic,index=2");
    echo("\nCreate SimpleDynamic MBean...");
    mbsc.createMBean("SimpleDynamic", dynMBeanName, null, null);
    waitForEnterPressed();

    // Get MBean count
    //
    echo("\nMBean count = " + mbsc.getMBeanCount());

    // Query MBean names
    //
    echo("\nQuery MBeanServer MBeans:");
    Set names = mbsc.queryNames(null, null);
    for (Iterator i = names.iterator(); i.hasNext(); ) {
    echo("\tObjectName = " + (ObjectName) i.next());
    }
    waitForEnterPressed();

    // -------------------------------
    // Manage the SimpleStandard MBean
    // -------------------------------
    echo("\n>>> Perform operations on SimpleStandard MBean <<<");

    // Get State attribute in SimpleStandard MBean
    //
    echo("\nState = " + mbsc.getAttribute(stdMBeanName, "State"));

    // Set State attribute in SimpleStandard MBean
    //
    mbsc.setAttribute(stdMBeanName,
    new Attribute("State", "changed state"));

    // Get State attribute in SimpleStandard MBean
    //
    // Another way of interacting with a given MBean is through a
    // dedicated proxy instead of going directly through the MBean
    // server connection
    //
    SimpleStandardMBean proxy = (SimpleStandardMBean)
    MBeanServerInvocationHandler.newProxyInstance(
    mbsc,
    stdMBeanName,
    SimpleStandardMBean.class,
    true);
    echo("\nState = " + proxy.getState());

    // Add notification listener on SimpleStandard MBean
    //
    echo("\nAdd notification listener...");
    mbsc.addNotificationListener(stdMBeanName, listener, null, null);

    // Invoke "reset" in SimpleStandard MBean
    //
    // Calling "reset" makes the SimpleStandard MBean emit a
    // notification that will be received by the registered
    // ClientListener.
    //
    echo("\nInvoke reset() in SimpleStandard MBean...");
    mbsc.invoke(stdMBeanName, "reset", null, null);

    // Sleep for 2 seconds in order to have time to receive the
    // notification before removing the notification listener.
    //
    echo("\nWaiting for notification...");
    sleep(2000);

    // Remove notification listener on SimpleStandard MBean
    //
    echo("\nRemove notification listener...");
    mbsc.removeNotificationListener(stdMBeanName, listener);

    // Unregister SimpleStandard MBean
    //
    echo("\nUnregister SimpleStandard MBean...");
    mbsc.unregisterMBean(stdMBeanName);
    waitForEnterPressed();

    // ------------------------------
    // Manage the SimpleDynamic MBean
    // ------------------------------
    echo("\n>>> Perform operations on SimpleDynamic MBean <<<");

    // Get State attribute in SimpleDynamic MBean
    //
    echo("\nState = " + mbsc.getAttribute(dynMBeanName, "State"));

    // Set State attribute in SimpleDynamic MBean
    //
    mbsc.setAttribute(dynMBeanName,
    new Attribute("State", "changed state"));

    // Get State attribute in SimpleDynamic MBean
    //
    echo("\nState = " +
    mbsc.getAttribute(dynMBeanName, "State"));

    // Add notification listener on SimpleDynamic MBean
    //
    echo("\nAdd notification listener...");
    mbsc.addNotificationListener(dynMBeanName, listener, null, null);

    // Invoke "reset" in SimpleDynamic MBean
    //
    // Calling "reset" makes the SimpleDynamic MBean emit a
    // notification that will be received by the registered
    // ClientListener.
    //
    echo("\nInvoke reset() in SimpleDynamic MBean...");
    mbsc.invoke(dynMBeanName, "reset", null, null);

    // Sleep for 2 seconds in order to have time to receive the
    // notification before removing the notification listener.
    //
    echo("\nWaiting for notification...");
    sleep(2000);

    // Remove notification listener on SimpleDynamic MBean
    //
    echo("\nRemove notification listener...");
    mbsc.removeNotificationListener(dynMBeanName, listener);

    // Unregister SimpleDynamic MBean
    //
    echo("\nUnregister SimpleDynamic MBean...");
    mbsc.unregisterMBean(dynMBeanName);
    waitForEnterPressed();

    // Close MBeanServer connection
    //
    echo("\nClose the connection to the server");
    jmxc.close();
    echo("\nBye! Bye!");
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    private static void echo(String msg) {
    System.out.println(msg);
    }

    private static void sleep(int millis) {
    try {
    Thread.sleep(millis);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }

    private static void waitForEnterPressed() {
    try {
    echo("\nPress <Enter> to continue...");
    System.in.read();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

  2. #2
    Nouveau membre du Club
    Inscrit en
    Août 2009
    Messages
    49
    Détails du profil
    Informations forums :
    Inscription : Août 2009
    Messages : 49
    Points : 37
    Points
    37
    Par défaut
    J'avoue que j'ai le même problème que toi j'essaye désesperrement d'insérer des MBean dans mon serveur JONAS à distance pour des besoins de statistique mais celui-ci refuse de les prendre en compte. Par contre moi dans ma pile de trace j'ai un classnNotFounException sur le mbean. Tu as mis la trace complète. Moi elle à lieu après celle que tu as ?

Discussions similaires

  1. Réponses: 3
    Dernier message: 09/12/2011, 16h58
  2. Réponses: 1
    Dernier message: 30/05/2008, 18h34
  3. [JMX] Problème avec MBeanServer
    Par ploxien dans le forum API standards et tierces
    Réponses: 1
    Dernier message: 13/11/2007, 12h20
  4. Jboss 4.0.5, Jmx, Mbean
    Par nakata77 dans le forum Wildfly/JBoss
    Réponses: 1
    Dernier message: 29/01/2007, 15h48
  5. Problème avec la JMX console (configuration MBean)
    Par FredKéKé dans le forum Spring
    Réponses: 8
    Dernier message: 16/01/2007, 12h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo